Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly
- }
- class WPF_WPComplete extends WPF_Integrations_Base {
- /**
- * Gets things started
- *
- * @access public
- * @return void
- */
- public function init() {
- $this->slug = 'wp-complete';
- // Apply tags on course completion
- add_action( 'wpcomplete_mark_completed', array( $this, 'button_complete' ), 10, 1 );
- // Settings
- add_action( 'wpf_meta_box_content', array( $this, 'meta_box_content' ), 40, 2 );
- }
- /**
- * Triggered when course / lesson / button marked complete
- *
- * @access public
- * @return void
- */
- public function button_complete( $button_info ) {
- $wpf_settings = get_post_meta( $button_info['post_id'], 'wpf-settings', true );
- if ( ! empty( $wpf_settings ) && ! empty( $wpf_settings['apply_tags_wpc_complete'] ) ) {
- wp_fusion()->user->apply_tags( $wpf_settings['apply_tags_wpc_complete'], $button_info['user_id'] );
- }
- }
- /**
- * Adds wp-complete fields to WPF meta box
- *
- * @access public
- * @return void
- */
- public function meta_box_content( $post, $settings ) {
- echo '<hr />';
- echo '<p><strong>WPComplete:</strong></p>';
- echo '<p><label for="wpf-apply-tags-wpc-complete"><small>' . __( 'Apply these tags when marked complete', 'wp-fusion' ) . ':</small></label>';
- if( ! isset( $settings['apply_tags_wpc_complete'] ) ) {
- $settings['apply_tags_wpc_complete'] = array();
- }
- wpf_render_tag_multiselect( array( 'setting' => $settings['apply_tags_wpc_complete'], 'meta_name' => 'wpf-settings', 'field_id' => 'apply_tags_wpc_complete' ) );
- echo '</p>';
- }
- }
- new WPF_WPComplete;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement