Advertisement
verygoodplugins

Untitled

Apr 23rd, 2020
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2.  
  3. if ( ! defined( 'ABSPATH' ) ) {
  4.     exit; // Exit if accessed directly
  5. }
  6.  
  7.  
  8. class WPF_WPComplete extends WPF_Integrations_Base {
  9.  
  10.     /**
  11.      * Gets things started
  12.      *
  13.      * @access  public
  14.      * @return  void
  15.      */
  16.  
  17.     public function init() {
  18.  
  19.         $this->slug = 'wp-complete';
  20.  
  21.         // Apply tags on course completion
  22.         add_action( 'wpcomplete_mark_completed', array( $this, 'button_complete' ), 10, 1 );
  23.  
  24.         // Settings
  25.         add_action( 'wpf_meta_box_content', array( $this, 'meta_box_content' ), 40, 2 );
  26.  
  27.     }
  28.  
  29.     /**
  30.      * Triggered when course / lesson / button marked complete
  31.      *
  32.      * @access public
  33.      * @return void
  34.      */
  35.  
  36.     public function button_complete( $button_info ) {
  37.  
  38.         $wpf_settings = get_post_meta( $button_info['post_id'], 'wpf-settings', true );
  39.  
  40.         if ( ! empty( $wpf_settings ) && ! empty( $wpf_settings['apply_tags_wpc_complete'] ) ) {
  41.             wp_fusion()->user->apply_tags( $wpf_settings['apply_tags_wpc_complete'], $button_info['user_id'] );
  42.         }
  43.  
  44.     }
  45.  
  46.  
  47.     /**
  48.      * Adds wp-complete fields to WPF meta box
  49.      *
  50.      * @access public
  51.      * @return void
  52.      */
  53.  
  54.     public function meta_box_content( $post, $settings ) {
  55.  
  56.         echo '<hr />';
  57.         echo '<p><strong>WPComplete:</strong></p>';
  58.  
  59.         echo '<p><label for="wpf-apply-tags-wpc-complete"><small>' . __( 'Apply these tags when marked complete', 'wp-fusion' ) . ':</small></label>';
  60.  
  61.         if( ! isset( $settings['apply_tags_wpc_complete'] ) ) {
  62.             $settings['apply_tags_wpc_complete'] = array();
  63.         }
  64.  
  65.         wpf_render_tag_multiselect( array( 'setting' => $settings['apply_tags_wpc_complete'], 'meta_name' => 'wpf-settings', 'field_id' => 'apply_tags_wpc_complete' ) );
  66.  
  67.         echo '</p>';
  68.  
  69.  
  70.     }
  71.  
  72. }
  73.  
  74. new WPF_WPComplete;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement