コード例 #1
0
ファイル: Widget.php プロジェクト: venturepact/blog
 /**
  * Outputs the widget within the widgetized area.
  *
  * @since 1.0.0
  *
  * @param array $args     The default widget arguments.
  * @param array $instance The input settings for the current widget instance.
  *
  * @return void
  */
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     $optin_id = $instance['optin_monster_id'];
     do_action('optin_monster_api_widget_before_output', $args, $instance);
     echo $args['before_widget'];
     do_action('optin_monster_api_widget_before_title', $args, $instance);
     // If a title exists, output it.
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     do_action('optin_monster_api_widget_before_optin', $args, $instance);
     // If a optin has been selected, output it.
     if ($optin_id) {
         // Grab the optin object. If it does not exist, return early.
         $optin = absint($optin_id) ? $this->base->get_optin($optin_id) : $this->base->get_optin_by_slug($optin_id);
         if (!$optin) {
             return;
         }
         // If in test mode but not logged in, skip over the optin.
         $test = (bool) get_post_meta($optin->ID, '_omapi_test', true);
         if ($test && !is_user_logged_in()) {
             return;
         }
         // Load the optin.
         optin_monster($optin->ID);
     }
     do_action('optin_monster_api_widget_after_optin', $args, $instance);
     echo $args['after_widget'];
     do_action('optin_monster_api_widget_after_output', $args, $instance);
 }
コード例 #2
0
 /**
  * Primary template tag for outputting OptinMonster optins in templates (v1).
  *
  * @since 1.0.0
  *
  * @param int	 $string The post name of the optin to load.
  * @param bool	 $return Flag to echo or return the optin HTML.
  */
 function optin_monster_tag($id, $return = false)
 {
     // Return the v2 template tag.
     return optin_monster($id, 'slug', array(), $return);
 }
コード例 #3
0
ファイル: widget.php プロジェクト: venturepact/blog
 /**
  * Outputs the widget within the widgetized area.
  *
  * @since 2.0.0
  *
  * @param array $args     The default widget arguments.
  * @param array $instance The input settings for the current widget instance.
  *
  * @return void
  */
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     $optin_id = $instance['optin_monster_id'];
     do_action('optin_monster_widget_before_output', $args, $instance);
     echo $args['before_widget'];
     do_action('optin_monster_widget_before_title', $args, $instance);
     // If a title exists, output it.
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     do_action('optin_monster_widget_before_optin', $args, $instance);
     // If a optin has been selected, output it.
     if ($optin_id) {
         // If we are in preview mode, don't output the widget.
         if (Optin_Monster_Output::get_instance()->is_preview()) {
             return;
         }
         // Grab the optin object. If it does not exist, return early.
         $optin = absint($optin_id) ? Optin_Monster::get_instance()->get_optin($optin_id) : Optin_Monster::get_instance()->get_optin_by_slug($optin_id);
         if (!$optin) {
             return;
         }
         // Check for split tests.
         $original = $optin;
         $split_tests = Optin_Monster::get_instance()->get_split_tests($optin->ID);
         if ($split_tests) {
             // Merge the main optin with the split tests, shuffle the array, and set the optin to the first item in the array.
             $split_tests[] = $optin;
             shuffle($split_tests);
             $optin = $split_tests[0];
         }
         // If a clone is selected but it is not enabled, default back to parent optin.
         $clone = get_post_meta($optin->ID, '_om_is_clone', true);
         if (!empty($clone)) {
             $meta = get_post_meta($optin->ID, '_om_meta', true);
             if (empty($meta['display']['enabled']) || !$meta['display']['enabled']) {
                 $optin = $original;
             }
         }
         // If in test mode but not logged in, skip over the optin.
         $test = get_post_meta($optin->ID, '_om_test_mode', true);
         if (!empty($test) && !is_user_logged_in()) {
             return;
         }
         // Load the optin.
         optin_monster($optin->ID);
     }
     do_action('optin_monster_widget_after_optin', $args, $instance);
     echo $args['after_widget'];
     do_action('optin_monster_widget_after_output', $args, $instance);
 }