Esempio n. 1
0
 /**
  * PHPDOC
  *
  * @param int     $ori_id         PHPDOC
  * @param int     $overwriting_id PHPDOC
  * @param boolean $meta           PHPDOC
  *                                Default: `true`.
  * @param boolean $categories     PHPDOC
  *                                Default: `true`.
  * @param boolean $tags           PHPDOC
  *                                Default: `true`.
  *
  * @return void
  *
  * @since PHPDOC
  */
 public static function overwrite($ori_id, $overwriting_id, $meta = true, $categories = true, $tags = true)
 {
     $ori = get_post($ori_id, ARRAY_A);
     if (!$ori) {
         return;
     }
     $overwriting = get_post($overwriting_id, ARRAY_A);
     if (!$overwriting) {
         return;
     }
     require_once NELIOAB_UTILS_DIR . '/optimize-press-support.php';
     NelioABOptimizePressSupport::make_post_compatible_with_optimizepress($ori_id, $overwriting_id);
     $ori['post_title'] = $overwriting['post_title'];
     $ori['post_content'] = $overwriting['post_content'];
     $ori['post_excerpt'] = $overwriting['post_excerpt'];
     $ori['post_parent'] = $overwriting['post_parent'];
     wp_update_post($ori);
     if ($meta) {
         NelioABWpHelper::copy_meta_info($overwriting_id, $ori_id);
     }
     NelioABWpHelper::copy_terms($overwriting_id, $ori_id, $categories, $tags);
 }
 /**
  * PHPDOC
  *
  * @return void
  *
  * @since PHPDOC
  */
 public function hook_to_wordpress()
 {
     $this->are_comments_from_original_loaded = false;
     // Page/Post alt exp related
     add_action('wp', array(&$this, 'do_late_hooks'));
     // Make sure that the title is replaced everywhere
     add_filter('wp_title', array(&$this, 'fix_title_for_landing_page'), 10, 2);
     add_filter('the_posts', array(&$this, 'the_posts_intercept'));
     add_filter('get_post_metadata', array(&$this, 'load_proper_page_template'), 10, 3);
     add_action('pre_get_comments', array(&$this, 'load_comments_from_original'));
     add_filter('comments_array', array(&$this, 'prepare_comments_form'));
     add_filter('get_comments_number', array(&$this, 'load_comments_number_from_original'));
     add_filter('post_link', array(&$this, 'use_originals_post_link'));
     add_filter('page_link', array(&$this, 'use_originals_post_link'));
     add_filter('post_type_link', array(&$this, 'use_originals_post_link'));
     add_filter('get_shortlink', array(&$this, 'use_originals_shortlink'), 10, 2);
     add_action('wp_get_nav_menu_items', array(&$this, 'show_the_appropriate_menu'), 10, 3);
     add_action('wp_get_nav_menu_items', array(&$this, 'highlight_current_menu_option'), 11);
     add_action('nelioab_footer', array(&$this, 'print_list_of_applied_headlines'));
     add_filter('nelioab_ajax_result', array(&$this, 'add_list_of_applied_headlines'));
     add_action('wp_footer', array(&$this, 'include_css_alternative_fragments_if_any'));
     add_action('wp_footer', array(&$this, 'do_nelioab_footer'));
     /**
      * Headline Experiments modify TITLE, FEATURED IMAGE and EXCERPT.
      * Let's add the three filters!
      */
     add_filter('the_title', array(&$this, 'get_consistent_title'), 10, 2);
     add_filter('get_the_excerpt', array(&$this, 'get_consistent_excerpt'), 10);
     add_filter('the_content', array(&$this, 'get_consistent_content'), 10);
     add_filter('get_post_metadata', array(&$this, 'get_consistent_featured_image'), 10, 4);
     add_filter('the_title', array(&$this, 'replace_headline_title'), 10, 2);
     add_filter('get_the_excerpt', array(&$this, 'replace_headline_excerpt'), 10);
     add_filter('get_post_metadata', array(&$this, 'fix_headline_featured_image'), 10, 4);
     /**
      * Support with other plugins.
      * Compatibility tweaks for testing OptimizePress pages.
      */
     require_once NELIOAB_UTILS_DIR . '/optimize-press-support.php';
     if (NelioABOptimizePressSupport::is_plugin_active()) {
         add_filter('template_redirect', array('NelioABOptimizePressSupport', 'apply_abtesting_to_optimize_press_pages'));
     }
     /**
      * Support with other plugins.
      * Compatibility tweaks with Member Access.
      */
     require_once NELIOAB_UTILS_DIR . '/member-access-support.php';
     if (NelioABMemberAccessSupport::is_plugin_active()) {
         add_action('wp_loaded', array('NelioABMemberAccessSupport', 'unhook_redirections'));
     }
     /**
      *  Hooks for Gravity Forms and Contact Form 7
      */
     // Monitoring submissions:
     add_action('gform_after_submission', array(&$this, 'track_gf_submission'), 10, 2);
     add_action('wpcf7_submit', array(&$this, 'track_cf7_submission'), 10, 2);
     /**
      * Basic WooCommerce support (first version of Custom Post Types support).
      * @since 4.1.0
      */
     add_action('woocommerce_product_object', array($this, 'wc_make_alternative_product_purchasable'));
 }