Exemple #1
0
 /**
  * Sets our object instance and base class instance.
  *
  * @since 1.0.0
  */
 public function set()
 {
     self::$instance = $this;
     $this->base = OMAPI::get_instance();
     $this->view = isset($_GET['optin_monster_api_view']) ? stripslashes($_GET['optin_monster_api_view']) : $this->base->get_view();
     $this->optin = isset($_GET['optin_monster_api_id']) ? $this->base->get_optin(absint($_GET['optin_monster_api_id'])) : false;
 }
Exemple #2
0
 /**
  * Constructor. Sets up and creates the widget with appropriate settings.
  *
  * @since 1.0.0
  */
 public function __construct()
 {
     // Load the base class object.
     $this->base = OMAPI::get_instance();
     $widget_ops = apply_filters('optin_monster_api_widget_ops', array('classname' => 'optin-monster-api', 'description' => __('Place an OptinMonster optin into a widgetized area.', 'optin-monster-api')));
     $control_ops = apply_filters('optin_monster_api_widget_control_ops', array('id_base' => 'optin-monster-api', 'height' => 350, 'width' => 225));
     parent::__construct('optin-monster-api', apply_filters('optin_monster_api_widget_name', __('OptinMonster', 'optin-monster-api')), $widget_ops, $control_ops);
 }
/**
 * Fired when the plugin is uninstalled.
 *
 * @since 1.0.0
 *
 * @global object $wpdb The WordPress database object.
 */
function optin_monster_api_uninstall_hook()
{
    $instance = OMAPI::get_instance();
    global $wpdb;
    if (is_multisite()) {
        $site_list = $wpdb->get_results("SELECT * FROM {$wpdb->blogs} ORDER BY blog_id");
        foreach ((array) $site_list as $site) {
            switch_to_blog($site->blog_id);
            delete_option('optin_monster_api');
            restore_current_blog();
        }
    } else {
        delete_option('optin_monster_api');
    }
}
Exemple #4
0
 /**
  * Sets our object instance and base class instance.
  *
  * @since 1.0.0
  */
 public function set()
 {
     self::$instance = $this;
     $this->base = OMAPI::get_instance();
     $this->view = 'ajax';
 }
Exemple #5
0
 /**
  * Sets our object instance and base class instance.
  *
  * @since 1.0.0
  */
 public function set()
 {
     self::$instance = $this;
     $this->base = OMAPI::get_instance();
     $this->fields = apply_filters('optin_monster_api_output_fields', $this->fields);
 }
Exemple #6
0
 /**
  * Creates the shortcode for the plugin.
  *
  * @since 1.0.0
  *
  * @global object $post The current post object.
  *
  * @param array $atts Array of shortcode attributes.
  * @return string     The optin output.
  */
 public function shortcode($atts)
 {
     global $post;
     $optin_id = false;
     if (isset($atts['id'])) {
         $optin_id = (int) $atts['id'];
     } else {
         if (isset($atts['slug'])) {
             $optin = get_page_by_path($atts['slug'], OBJECT, 'omapi');
             if ($optin) {
                 $optin_id = $optin->ID;
             }
         } else {
             // A custom attribute must have been passed. Allow it to be filtered to grab the optin ID from a custom source.
             $optin_id = apply_filters('optin_monster_api_custom_optin_id', false, $atts, $post);
         }
     }
     // Allow the optin ID to be filtered before it is stored and used to create the optin output.
     $optin_id = apply_filters('optin_monster_api_pre_optin_id', $optin_id, $atts, $post);
     // If there is no optin, do nothing.
     if (!$optin_id) {
         return false;
     }
     // Try to grab the stored HTML.
     $optin = $this->base->get_optin($optin_id);
     $html = trim(html_entity_decode(stripslashes($optin->post_content), ENT_QUOTES), '\'');
     if (!$html) {
         return false;
     }
     // Make sure to apply shortcode filtering.
     OMAPI::get_instance()->output->set_slug($optin);
     // Possibly add support for Mailpoet.
     $mailpoet = get_post_meta($optin->ID, '_omapi_mailpoet', true);
     if ($mailpoet) {
         OMAPI::get_instance()->output->wp_helper();
     }
     // Return the HTML.
     return $html;
 }
Exemple #7
0
 /**
  * Class constructor.
  *
  * @since 1.0.0
  */
 public function __construct(OMAPI_Api $api)
 {
     $this->base = OMAPI::get_instance();
     $this->api = $api;
     $this->data = $this->gather_data();
 }
Exemple #8
0
 /**
  * Primary class constructor.
  *
  * @since 1.0.0
  *
  * @param string $route  The API route to target.
  * @param array $creds   Array of API credentials.
  * @param string $method The API method.
  */
 public function __construct($route, $creds, $method = 'POST')
 {
     // Set class properties.
     $this->route = $route;
     $this->protocol = $this->is_ssl() ? 'https://' : 'http://';
     $this->url = $this->protocol . $this->base . $this->route . '/';
     $this->method = $method;
     $this->user = $creds['user'];
     $this->key = $creds['key'];
     $this->plugin = OMAPI::get_instance()->plugin_slug;
 }