コード例 #1
0
 /**
  * Finds the correct value given the variation
  *
  * @param MIXED $value contains the non-variation value
  * @param INT $post_id ID of landing page being loaded
  * @param ARRAY $field wide array of data belonging to custom field (not leveraged in this method)
  *
  * @returns MIXED $new_value value mapped to variation.
  */
 public static function load_value($value, $post_id, $field)
 {
     global $post;
     if (!isset($post) || $post->post_type != 'landing-page') {
         return $value;
     }
     $vid = Landing_Pages_Variations::get_new_variation_reference_id($post->ID);
     $settings = Landing_Pages_Meta::get_settings($post->ID);
     $variations = isset($settings['variations']) ? $settings['variations'] : null;
     if (!$variations[$vid]['acf']) {
         return self::load_legacy_value($value, $post_id, $field);
     }
     if (isset($variations[$vid]['acf'])) {
         $new_value = self::search_field_array($variations[$vid]['acf'], $field);
         /* sometimes value is an array count when new_value believes it should be an array in this case get new count */
         if (!is_array($value) && is_array($new_value)) {
             $value = count($new_value);
         } else {
             if ($new_value) {
                 $value = $new_value;
             }
         }
         /* acf lite isn't processing return values correctly */
         $value = self::afc_free_value_formatting($value, $field);
     }
     return $value;
 }
コード例 #2
0
    /**
     * Notice to tell people that variation A needs to be save first
     */
    public static function save_legacy_landing_page()
    {
        global $post;
        $screen = get_current_screen();
        if (!isset($post) || $screen->id == 'landing-pages' || $screen->id == 'edit-landing-page' || $post->post_status != 'publish') {
            return;
        }
        $extension_data = lp_get_extension_data();
        $current_template = Landing_Pages_Variations::get_current_template($post->ID);
        if (!isset($extension_data[$current_template]['info']['data_type']) || $extension_data[$current_template]['info']['data_type'] != 'acf4') {
            return;
        }
        $settings = Landing_Pages_Meta::get_settings($post->ID);
        $variations = isset($settings['variations']) ? $settings['variations'] : null;
        if ($variations) {
            return;
        }
        ?>
        <style type='text/css'>
            #post {
                display: none;
            }

            .wrap h1 {
                display: none;
            }
        </style>
        <script type='text/javascript'>
            jQuery(document).ready(function () {
                jQuery('#update_landing_page').click(function () {
                    jQuery('#post').submit();
                });

            });
        </script>
        <div class="error">
            <p>
                <?php 
        echo sprintf(__('This landing page requires a database update to continue. %s %sUpdate Now%s', 'landing-pages'), '<br><br>', '<button class="button button-primary" id="update_landing_page">', '</button>');
        ?>
            </p>
        </div>
        <?php 
    }
コード例 #3
0
 /**
  * Finds the correct value given the variation
  *
  * @param MIXED $value contains the non-variation value
  * @param INT $post_id ID of landing page being loaded
  * @param ARRAY $field wide array of data belonging to custom field (not leveraged in this method)
  *
  * @returns MIXED $new_value value mapped to variation.
  */
 public static function load_value($value, $post_id, $field)
 {
     global $post;
     if (!isset($post) || $post->post_type != 'landing-page') {
         return $value;
     }
     $vid = Landing_Pages_Variations::get_new_variation_reference_id($post->ID);
     $settings = Landing_Pages_Meta::get_settings($post->ID);
     $variations = isset($settings['variations']) ? $settings['variations'] : null;
     /* If there is no ACF data for this template attempt to pull values from the legacy postmeta values */
     if (!isset($variations[$vid]['acf']) || !$variations[$vid]['acf']) {
         return self::load_legacy_value($value, $post_id, $field);
     }
     if (isset($variations[$vid]['acf'])) {
         $new_value = self::search_field_array($variations[$vid]['acf'], $field);
         /* sometimes value is an array count when new_value believes it should be an array in this case get new count */
         if (!is_array($value) && is_array($new_value)) {
             $value = count($new_value);
         } else {
             if ($new_value) {
                 $value = $new_value;
             }
         }
         /* acf lite isn't processing return values correctly - ignore repeater subfields */
         if (!is_admin() && defined('ACF_FREE')) {
             $value = self::acf_free_value_formatting($value, $field);
         }
         if (!is_admin() && is_string($value)) {
             $value = do_shortcode($value);
         }
         /* handle non acf5 template return formatting */
         if (defined('ACF_PRO')) {
             $value = self::acf_check_if_acf4($value, $field);
         }
     }
     return $value;
 }