コード例 #1
0
 /**
  * Initialize the public part of the plugin on every front-end page:
  * Determine how the popup is loaded.
  *
  * @since  4.6
  */
 public function init_public()
 {
     // Load plugin settings.
     $settings = IncPopupDatabase::get_settings();
     // Initialize javascript-data.
     $this->script_data['ajaxurl'] = '';
     $this->script_data['do'] = 'get_data';
     $this->script_data['ajax_data'] = array();
     // Find the current loading method.
     $cur_method = isset($settings['loadingmethod']) ? $settings['loadingmethod'] : 'ajax';
     if (empty($cur_method)) {
         $cur_method = 'ajax';
     }
     if (isset($_POST['_po_method_'])) {
         $cur_method = $_POST['_po_method_'];
     }
     /*
      * Apply the specific loading method to include the popup on the page.
      * Details to the loading methods are documented in the header comment
      * of the "load_method_xyz()" functions.
      */
     switch ($cur_method) {
         case 'ajax':
             // former 'external'
             $this->load_method_ajax();
             break;
         case 'front':
             // former 'frontloading'
             $this->load_method_front();
             if (isset($_GET['action']) && 'inc_popup' == $_GET['action']) {
                 $this->ajax_load_popup();
             }
             break;
         case 'footer':
             $this->load_method_footer();
             break;
         case 'raw':
             // Set via form field "_po_method_"
             $this->load_method_raw();
             break;
         default:
             /**
              * Custom loading handler can be processed by an add-on.
              */
             do_action('popup-init-loading-method', $cur_method, $this);
             break;
     }
 }
コード例 #2
0
 /**
  * Parses the specified content and looks for shortcodes that are not
  * compatible with the current PopUp loading method.
  *
  * The function does not return a value, but if incompatible shortcodes are
  * detected a new Admin Notification will be generated which is displayed to
  * the user after the page has finished loading.
  *
  * @since  4.7.0
  * @param  string $content
  */
 public static function validate_shortcodes($content)
 {
     $settings = IncPopupDatabase::get_settings();
     $method = isset($settings['loadingmethod']) ? $settings['loadingmethod'] : 'ajax';
     // Check for specific/frequently used shortcodes.
     if ('footer' !== $method && preg_match('#\\[gravityforms?(\\s.*?\\]|\\])#', $content)) {
         lib2()->ui->admin_message(sprintf(__('You are using Gravity Forms inside this PopUp. It is best to switch to the <a href="%s">loading method</a> "Page Footer" to ensure the form works as expected.', PO_LANG), 'edit.php?post_type=' . IncPopupItem::POST_TYPE . '&page=settings'), 'err');
     }
     // General check for shortcode incompatibility
     switch ($method) {
         case 'ajax':
         case 'anonymous':
             // Check if the content contains any of the Front-Shortcodes:
             $check = IncPopupAddon_HeaderFooter::check();
             $content = do_shortcode($content);
             foreach ($check->shortcodes as $code) {
                 $match = array();
                 if (preg_match('#\\[' . $code . '(\\s.*?\\]|\\])#', $content, $match)) {
                     lib2()->ui->admin_message(sprintf(__('Shortcode <code>%s</code> requires a different <a href="%s">loading method</a> to work.<br />Try "Page Footer", though sometimes the method "Custom AJAX" also works (please test the result)', PO_LANG), $match[0], 'edit.php?post_type=' . IncPopupItem::POST_TYPE . '&page=settings'), 'err');
                 }
             }
             break;
         case 'footer':
         case 'front':
             // Nothing needs to be validated here...
             break;
         default:
             //lib2()->ui->admin_message( 'Shortcode-Check not defined for: ' . $method );
     }
 }
コード例 #3
0
<?php

global $shortcode_tags;
// Theme compatibility.
$theme_compat = IncPopupAddon_HeaderFooter::check();
$settings = IncPopupDatabase::get_settings();
$cur_method = $settings['loadingmethod'];
// Shortcodes with restrictions.
$limited = array('app_.*', '.*-form.*', '.*_form.*');
$shortcodes = array();
// Add Admin-Shortcodes to the list.
foreach ($shortcode_tags as $code => $handler) {
    if (!isset($shortcodes[$code])) {
        $shortcodes[$code] = '';
    }
    $shortcodes[$code] .= 'sc-admin ';
}
// Add Front-End Shortcodes to the list.
foreach ($theme_compat->shortcodes as $code) {
    if (!isset($shortcodes[$code])) {
        $shortcodes[$code] = '';
    }
    $shortcodes[$code] .= 'sc-front ';
}
foreach ($shortcodes as $code => $compat) {
    foreach ($limited as $pattern) {
        if (preg_match('/^' . $pattern . '$/i', $code)) {
            $shortcodes[$code] = $compat . 'sc-limited ';
        }
    }
}
コード例 #4
0
 /**
  * Called every time the settings page is loaded. Saves changes.
  *
  * @since  4.6.0
  */
 public static function handle_settings_update()
 {
     lib2()->array->equip_post('action', 'po_option');
     if ('updatesettings' == $_POST['action']) {
         check_admin_referer('update-popup-settings');
         $old_settings = IncPopupDatabase::get_settings();
         $settings = array();
         $settings['loadingmethod'] = $_POST['po_option']['loadingmethod'];
         if (isset($_POST['po_option']['geo_lookup'])) {
             $settings['geo_lookup'] = $_POST['po_option']['geo_lookup'];
             $settings['geo_db'] = 'geo_db' === $settings['geo_lookup'];
         }
         $rules = $_POST['po_option']['rules'];
         if (!is_array($rules)) {
             $rules = array();
         }
         $settings['rules'] = array_keys($rules);
         IncPopupDatabase::set_settings($settings);
         lib2()->ui->admin_message(__('Your settings have been updated.', PO_LANG));
         $redirect_url = esc_url_raw(remove_query_arg(array('message', 'count'), wp_get_referer()));
         wp_safe_redirect($redirect_url);
         die;
     }
 }
コード例 #5
0
ファイル: class-popup-base.php プロジェクト: ultr0/TM-FreeTV
 /**
  * Loads the active Add-On files.
  *
  * @since  4.6
  */
 public static function load_optional_files()
 {
     $settings = IncPopupDatabase::get_settings();
     if ($settings['geo_db']) {
         IncPopupAddon_GeoDB::init();
     }
     // $available uses apply_filter to customize the results.
     $available = self::get_rules();
     foreach ($available as $rule) {
         $path = PO_INC_DIR . 'rules/' . $rule;
         if (in_array($rule, $settings['rules']) && file_exists($path)) {
             include_once $path;
         }
     }
 }
コード例 #6
0
 /**
  * Returns the lookup-service details
  *
  * @since  4.6.1.1
  * @return object Service object for geo lookup
  */
 protected static function get_service($type = null)
 {
     $service = false;
     if (null === $type) {
         // Default service.
         if (defined('PO_REMOTE_IP_URL') && strlen(PO_REMOTE_IP_URL) > 5) {
             $type = '';
         } else {
             $settings = IncPopupDatabase::get_settings();
             $type = @$settings['geo_lookup'];
         }
     }
     if ('' == $type) {
         $service = (object) array('url' => PO_REMOTE_IP_URL, 'label' => 'wp-config.php', 'type' => 'text');
     } else {
         if ('geo_db' === $type) {
             $service = (object) array('url' => 'db', 'label' => __('Local IP Lookup Table', PO_LANG), 'type' => 'text');
         } else {
             $geo_service = IncPopupDatabase::get_geo_services();
             $service = @$geo_service[$type];
         }
     }
     return $service;
 }
 /**
  * Replaces selectors in the PopUp HTML/CSS code
  *
  * @since  1.0.0
  * @param  array $data Data collection that is printed to javascript.
  * @param  IncPopupItem $popup The original popup object.
  * @return array Modified data collection.
  */
 public static function filter_script_data($script_data, $popup)
 {
     $settings = IncPopupDatabase::get_settings();
     if (self::METHOD != $settings['loadingmethod']) {
         return $script_data;
     }
     if (!empty($script_data['html']) && !empty($script_data['styles'])) {
         $script_data['html'] = self::_filter($script_data['html'], true);
         $script_data['styles'] = self::_filter($script_data['styles']);
     }
     return $script_data;
 }