public function json_preview()
 {
     $data = stripslashes_deep($_POST);
     $opts = $data['opts'];
     $message = (object) array('ID' => true, 'post_title' => __('Slide-In Preview', 'wdsi'), 'post_content' => __('This preview message will demonstrate the current settings for position, width, theme, variation and color scheme. Please, don\'t forget to save your changes once you\'re happy with the result.', 'wdsi'));
     $opts['show_for-time'] = DAY_IN_SECONDS;
     $out = Wdsi_SlideIn::message_markup($message, $opts, false);
     wp_send_json_success(array('out' => $out));
 }
 function create_advanced_box()
 {
     echo '' . '<input type="hidden" name="wdsi[allow_shortcodes]" value="" />' . '<input type="checkbox" name="wdsi[allow_shortcodes]" id="wdsi-allow_shortcodes" value="1" ' . ($this->_get_option('allow_shortcodes') ? 'checked="checked"' : '') . ' />' . '&nbsp;' . '<label for="wdsi-allow_shortcodes">' . __('Allow shortcodes', 'wdsi') . '</label>' . $this->_create_hint(__('Enabling this option will allow processing shortcodes in your slide-in messages.', 'wdsi')) . '';
     echo '' . '<input type="hidden" name="wdsi[allow_widgets]" value="" />' . '<input type="checkbox" name="wdsi[allow_widgets]" id="wdsi-allow_widgets" value="1" ' . ($this->_get_option('allow_widgets') ? 'checked="checked"' : '') . ' />' . '&nbsp;' . '<label for="wdsi-allow_widgets">' . __('Allow widgets', 'wdsi') . '</label>' . $this->_create_hint(__('Enabling this option will add a new sidebar that you can populate with widgets in Appearance &gt; Widgets.', 'wdsi')) . '';
     if (class_exists('MarketPress')) {
         echo '' . '<input type="hidden" name="wdsi[show_on_marketpress_pages]" value="" />' . '<input type="checkbox" name="wdsi[show_on_marketpress_pages]" id="wdsi-show_on_marketpress_pages" value="1" ' . ($this->_get_option('show_on_marketpress_pages') ? 'checked="checked"' : '') . ' />' . '&nbsp;' . '<label for="wdsi-show_on_marketpress_pages">' . __('Show on MarketPress pages (except products):', 'wdsi') . '</label>' . $this->_create_hint(__('Decide if you want your messages to appear on MarketPress virtual pages.', 'wdsi')) . '';
     }
     $hook = $this->_get_option('custom_injection_hook');
     $hook = $hook ? $hook : Wdsi_SlideIn::get_default_injection_hook();
     echo '' . '<label for="wdsi-custom_injection_hook">' . __('Custom injection hook', 'wdsi') . '</label>' . '&nbsp;' . '<input type="text" class="long" name="wdsi[custom_injection_hook]" id="wdsi-custom_injection_hook" value="' . esc_attr($hook) . '" />' . $this->_create_hint(__('Try a different injection hook if you experience problems with the default one. Leave empty for default.', 'wdsi')) . '';
 }
Exemplo n.º 3
0
        } else {
            // No textdomain is loaded because we can't determine the plugin location.
            // No point in trying to add textdomain to string and/or localizing it.
            wp_die(__('There was an issue determining where Slide In plugin is installed. Please reinstall.'));
        }
    }
}
$textdomain_handler('wdsi', false, WDSI_PLUGIN_SELF_DIRNAME . '/languages/');
require_once WDSI_PLUGIN_BASE_DIR . '/lib/class_wdsi_mailchimp.php';
require_once WDSI_PLUGIN_BASE_DIR . '/lib/class_wdsi_options.php';
require_once WDSI_PLUGIN_BASE_DIR . '/lib/functions.php';
/*
Wdsi_Options::populate();
*/
require_once WDSI_PLUGIN_BASE_DIR . '/lib/class_wdsi_slide_in.php';
Wdsi_SlideIn::init();
if (is_admin()) {
    // Setup dashboard notices
    if (file_exists(WDSI_PLUGIN_BASE_DIR . '/lib/external/wpmudev-dash-notification.php')) {
        global $wpmudev_notices;
        if (!is_array($wpmudev_notices)) {
            $wpmudev_notices = array();
        }
        $wpmudev_notices[] = array('id' => 694503, 'name' => 'Slide-In', 'screens' => array('edit-slide_in', 'slide_in_page_wdsi'));
        require_once WDSI_PLUGIN_BASE_DIR . '/lib/external/wpmudev-dash-notification.php';
    }
    // End dash bootstrap
    require_once WDSI_PLUGIN_BASE_DIR . '/lib/class_wdsi_admin_form_renderer.php';
    require_once WDSI_PLUGIN_BASE_DIR . '/lib/class_wdsi_admin_pages.php';
    Wdsi_AdminPages::serve();
} else {
 function add_message()
 {
     if (defined('WDSI_BOX_RENDERED')) {
         return false;
     }
     if ($this->_is_wrong_place()) {
         return false;
     }
     global $post;
     // if is selected as no show, also return false
     if (!empty($post->ID)) {
         $do_not_show = get_post_meta($post->ID, 'wdsi_do_not_show', true);
         if ($do_not_show) {
             return false;
         }
     }
     $opts = get_option('wdsi');
     $message = $this->_wdsi->get_message_data($post);
     if (!$message) {
         return false;
     }
     Wdsi_SlideIn::message_markup($message, $opts);
     define('WDSI_BOX_RENDERED', true);
 }
 public static function message_markup($message, $opts, $output = true)
 {
     if (empty($message->ID)) {
         return false;
     }
     $msg = get_post_meta($message->ID, 'wdsi', true);
     $type = get_post_meta($message->ID, 'wdsi-type', true);
     $services = wdsi_getval($msg, 'services');
     $services = $services ? $services : wdsi_getval($opts, 'services');
     $services = is_array($services) ? $services : array();
     $skip_script = wdsi_getval($opts, 'skip_script');
     $skip_script = is_array($skip_script) ? $skip_script : array();
     $no_count = wdsi_getval($opts, 'no_count');
     $no_count = is_array($no_count) ? $no_count : array();
     $content_type = wdsi_getval($type, 'content_type', 'text');
     if ('widgets' == $content_type && !$this->_data->get_option('allow_widgets')) {
         return false;
     }
     // Break on this
     $related_posts_count = wdsi_getval($type, 'related-posts_count', 3);
     $related_taxonomy = wdsi_getval($type, 'related-taxonomy', 'post_tag');
     $related_has_thumbnails = wdsi_getval($type, 'related-has_thumbnails');
     $mailchimp_placeholder = wdsi_getval($type, 'mailchimp-placeholder', '*****@*****.**');
     $mailchimp_position = wdsi_getval($type, 'mailchimp-position', 'after');
     $position = wdsi_getval($msg, 'position') ? $msg['position'] : wdsi_getval($opts, 'position');
     $position = $position ? $position : 'left';
     $percentage = $selector = $timeout = false;
     $condition = wdsi_getval($msg, 'show_after-condition') ? $msg['show_after-condition'] : wdsi_getval($opts, 'show_after-condition');
     $value = wdsi_getval($msg, 'show_after-rule') ? $msg['show_after-rule'] : wdsi_getval($opts, 'show_after-rule');
     switch ($condition) {
         case "selector":
             $selector = "#{$value}";
             $percentage = '0%';
             $timeout = '0s';
             break;
         case "timeout":
             $selector = false;
             $percentage = '0%';
             $timeout = sprintf('%ds', (int) $value);
             break;
         case "percentage":
         default:
             $selector = false;
             $percentage = sprintf('%d%%', (int) $value);
             $timeout = '0s';
             break;
     }
     $_theme = wdsi_getval($msg, 'theme') ? $msg['theme'] : wdsi_getval($opts, 'theme');
     $theme = $_theme && in_array($_theme, array_keys(Wdsi_SlideIn::get_appearance_themes())) ? $_theme : 'minimal';
     $_variation = wdsi_getval($msg, 'variation') ? $msg['variation'] : wdsi_getval($opts, 'variation');
     $variation = $_variation && in_array($_variation, array_keys(Wdsi_SlideIn::get_theme_variations())) ? $_variation : 'light';
     $_scheme = wdsi_getval($msg, 'scheme') ? $msg['scheme'] : wdsi_getval($opts, 'scheme');
     $scheme = $_scheme && in_array($_scheme, array_keys(Wdsi_SlideIn::get_variation_schemes())) ? $_scheme : 'red';
     $expire_after = wdsi_getval($msg, 'show_for-time') ? $msg['show_for-time'] : wdsi_getval($opts, 'show_for-time');
     $expire_after = $expire_after ? $expire_after : 10;
     $expire_unit = wdsi_getval($msg, 'show_for-unit') ? $msg['show_for-unit'] : wdsi_getval($opts, 'show_for-unit');
     $expire_unit = $expire_unit ? $expire_unit : 's';
     $expire_timeout = sprintf("%d%s", $expire_after, $expire_unit);
     $full_width = $width = false;
     $_width = wdsi_getval($msg, 'width') ? $msg['width'] : wdsi_getval($opts, 'width');
     if (!(int) $_width || 'full' == $width) {
         $full_width = 'slidein-full';
     } else {
         $width = 'style="width:' . (int) $_width . 'px;"';
     }
     $out = '';
     if (empty($output)) {
         ob_start();
     }
     require_once WDSI_PLUGIN_BASE_DIR . '/lib/forms/box_output.php';
     if (empty($output)) {
         $out = ob_get_contents();
         ob_end_clean();
     }
     return $out;
 }