function __construct() { $lp_data = lp_get_extension_data(); $final_data = array(); foreach ($lp_data as $key => $data) { $array_core_templates = array('countdown-lander', 'default', 'demo', 'dropcap', 'half-and-half', 'simple-two-column', 'super-slick', 'svtle', 'tubelar', 'rsvp-envelope', 'simple-solid-lite', 'three-column-lander'); if ($key == 'lp' || substr($key, 0, 4) == 'ext-') { continue; } if (isset($data['info']['data_type']) && $data['info']['data_type'] == 'metabox') { continue; } if (in_array($key, $array_core_templates)) { continue; } //if (stristr($data['category'],'Theme Integrated')) //continue; //echo "<br>"; if (isset($_POST['s']) && !empty($_POST['s'])) { if (!stristr($data['info']['label'], $_POST['s'])) { continue; } } if (isset($data['thumbnail'])) { $thumbnail = $data['thumbnail']; } else { if ($key == 'default') { $thumbnail = get_bloginfo('template_directory') . "/screenshot.png"; } else { $thumbnail = LANDINGPAGES_UPLOADS_URLPATH . $key . "/thumbnail.png"; } } $this_data['ID'] = $key; $this_data['template'] = $key; array_key_exists('info', $data) ? $this_data['name'] = $data['info']['label'] : ($this_data['name'] = $data['label']); array_key_exists('info', $data) ? $this_data['category'] = $data['info']['category'] : ($this_data['category'] = $data['category']); array_key_exists('info', $data) ? $this_data['description'] = $data['info']['description'] : ($this_data['description'] = $data['description']); $this_data['thumbnail'] = $thumbnail; if (isset($data['info']['version']) && !empty($data['info']['version'])) { $this_data['version'] = $data['info']['version']; } else { $this_data['version'] = "1.0.1"; } $final_data[] = $this_data; } //print_r($this_data);exit; $this->template_data = $final_data; //$this->_args = array(); $this->singular = 'ID'; $this->plural = 'ID'; $args = $this->_args; //print_r($args);exit; $args['plural'] = sanitize_key(''); $args['singular'] = sanitize_key(''); $this->_args = $args; }
function lp_add_template_license_keys($lp_global_settings) { $lp_data = lp_get_extension_data(); $lp_global_settings['lp-license-keys']['settings'][] = array('id' => 'template-license-keys-header', 'description' => "Head to http://www.inboundnow.com/ to retrieve your license key for this template.", 'type' => 'header', 'default' => '<h3 class="lp_global_settings_header">Template License Keys</h3>'); foreach ($lp_data as $key => $data) { $template_name = $lp_data[$key]['info']['label']; $lp_global_settings['lp-license-keys']['settings'][] = array('id' => $key, 'label' => $template_name, 'slug' => $key, 'description' => "Head to http://www.inboundnow.com/ to retrieve your license key for this template.", 'type' => 'license-key'); } return $lp_global_settings; }
} } //now add license key inputs to global settings area add_filter('lp_define_global_settings', 'lp_add_template_license_keys', 99, 1); function lp_add_template_license_keys($lp_global_settings) { $lp_data = lp_get_extension_data(); $lp_global_settings['lp-license-keys']['settings'][] = array('id' => 'template-license-keys-header', 'description' => __("Head to http://www.inboundnow.com/ to retrieve your license key for this template.", 'landing-pages'), 'type' => 'header', 'default' => '<h3 class="lp_global_settings_header">' . __('Template Licensing', 'landing-pages') . '</h3>'); /* get master license key */ $inboundnow_master_key = get_option('inboundnow_master_license_key', ''); foreach ($lp_data as $key => $data) { $array_core_templates = array('simple-solid-lite', 'countdown-lander', 'default', 'demo', 'dropcap', 'half-and-half', 'simple-two-column', 'super-slick', 'svtle', 'tubelar', 'rsvp-envelope', 'three-column-lander'); if ($key == 'lp' || substr($key, 0, 4) == 'ext-') { continue; } if (isset($data['info']['data_type']) && $data['info']['data_type'] == 'metabox') { continue; } if (in_array($key, $array_core_templates)) { continue; } $template_name = $lp_data[$key]['info']['label'];
function lp_save_meta($post_id) { global $post; $extension_data = lp_get_extension_data(); if (!isset($post) || isset($_POST['split_test'])) { return; } if ($post->post_type == 'revision') { return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || isset($_POST['post_type']) && $_POST['post_type'] == 'revision') { return; } if ($post->post_type == 'landing-page') { //print_r($extension_data);exit; foreach ($extension_data as $key => $data) { if ($key == 'lp') { // verify nonce if (!wp_verify_nonce($_POST["lp_{$key}_custom_fields_nonce"], 'lp-nonce')) { return $post_id; } $lp_custom_fields = $extension_data[$key]['settings']; foreach ($lp_custom_fields as $field) { $id = $key . "-" . $field['id']; $old = get_post_meta($post_id, $id, true); isset($_POST[$id]) ? $new = $_POST[$id] : ($new = null); if (isset($new) && $new != $old) { update_post_meta($post_id, $id, $new); } elseif ('' == $new && $old) { delete_post_meta($post_id, $id, $old); } } } else { if (substr($key, 0, 4) == 'ext-' || isset($data['info']['data_type']) && $data['info']['data_type'] == 'metabox') { $lp_custom_fields = $extension_data[$key]['settings']; // verify nonce if (!wp_verify_nonce($_POST["lp_{$key}_custom_fields_nonce"], 'lp-nonce')) { return $post_id; } // loop through fields and save the data foreach ($lp_custom_fields as $field) { $id = $key . "-" . $field['id']; if ($field['type'] == 'tax_select') { continue; } $old = get_post_meta($post_id, $id, true); isset($_POST[$id]) ? $new = $_POST[$id] : ($new = null); //echo "$old:".$new."<br>"; if (isset($new) && $new != $old) { update_post_meta($post_id, $id, $new); } elseif ('' == $new && $old) { delete_post_meta($post_id, $id, $old); } } // end foreach } else { if (isset($_POST['lp-selected-template']) && $_POST['lp-selected-template'] == $key) { $lp_custom_fields = $extension_data[$key]['settings']; // loop through fields and save the data foreach ($lp_custom_fields as $field) { $id = $key . "-" . $field['id']; if ($field['type'] == 'tax_select' || !isset($_POST[$id])) { continue; } $old = get_post_meta($post_id, $id, true); isset($_POST[$id]) ? $new = $_POST[$id] : ($new = null); //echo "$old:".$new."<br>"; exit; if (isset($new) && $new != $old) { update_post_meta($post_id, $id, $new); } elseif ('' == $new && $old) { delete_post_meta($post_id, $id, $old); } } } else { //echo "key:$key<br>"; } } } } // save taxonomies $post = get_post($post_id); //$category = $_POST['landing_page_category']; //wp_set_object_terms( $post_id, $category, 'landing_page_category' ); } }
/** * Notice to tell people that variation A needs to be save first */ public static function acf5_required() { 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 (defined('ACF_PRO') || !isset($extension_data[$current_template]['info']['data_type']) || $extension_data[$current_template]['info']['data_type'] != 'acf5') { return; } ?> <div class="error"> <p> <?php echo sprintf(__('This landing page template requires Inbound Pro Plugin (not available yet) or the %s Inbound Premium Template Support Extension%s to operate. Please download the best available option and activate it as a plugin to continue working with this template.', 'landing-pages'), '<a href="#linkhere">', '</a>'); ?> </p> </div> <?php }
/** * generate metabox html from extended dataset */ public static function display_extended_metabox($post, $args) { $extension_data = lp_get_extension_data(); $key = $args['args']['key']; if (!isset($extension_data[$key]['settings'])) { return; } self::render_fields($key, $extension_data[$key]['settings'], $post); }
function lp_admin_enqueue($hook) { global $post, $plugin_page; $screen = get_current_screen(); //print_r($screen); /* dequeue third party scripts */ global $wp_scripts; if (!empty($wp_scripts->queue)) { $store = $wp_scripts->queue; // store the scripts foreach ($wp_scripts->queue as $handle) { wp_dequeue_script($handle); } } //enqueue styles and scripts wp_enqueue_style('lp-admin-css', LANDINGPAGES_URLPATH . 'css/admin-style.css'); // Frontend Editor if ($plugin_page === 'lp-frontend-editor') { } if ($plugin_page === 'install-inbound-plugins') { wp_enqueue_script('inbound-install-plugins', LANDINGPAGES_URLPATH . 'js/admin/admin.install-plugins.js'); wp_enqueue_style('inbound-install-plugins-css', LANDINGPAGES_URLPATH . 'css/admin-install-plugins.css'); } // Store Options Page if (in_array($plugin_page, array('lp_store', 'lp_addons'))) { wp_dequeue_script('easyXDM'); wp_enqueue_script('easyXDM', LANDINGPAGES_URLPATH . 'js/libraries/easyXDM.debug.js'); //wp_enqueue_script('lp-js-store', LANDINGPAGES_URLPATH . 'js/admin/admin.store.js'); } // Admin enqueue - Landing Page CPT only if (isset($post) && 'landing-page' == $post->post_type || isset($_GET['post_type']) && $_GET['post_type'] == 'landing-page') { wp_enqueue_script(array('jquery', 'editor', 'thickbox', 'media-upload')); wp_enqueue_script('jpicker', LANDINGPAGES_URLPATH . 'js/libraries/jpicker/jpicker-1.1.6.min.js'); wp_localize_script('jpicker', 'jpicker', array('thispath' => LANDINGPAGES_URLPATH . 'js/libraries/jpicker/images/')); wp_enqueue_style('jpicker-css', LANDINGPAGES_URLPATH . 'js/libraries/jpicker/css/jPicker-1.1.6.min.css'); wp_dequeue_script('jquery-qtip'); wp_enqueue_script('jquery-qtip', LANDINGPAGES_URLPATH . 'js/libraries/jquery-qtip/jquery.qtip.min.js'); wp_enqueue_script('load-qtip', LANDINGPAGES_URLPATH . 'js/libraries/jquery-qtip/load.qtip.js', array('jquery-qtip')); wp_enqueue_style('qtip-css', LANDINGPAGES_URLPATH . 'css/jquery.qtip.min.css'); //Tool tip css wp_enqueue_style('lp-only-cpt-admin-css', LANDINGPAGES_URLPATH . 'css/admin-lp-cpt-only-style.css'); wp_enqueue_script('lp-admin-clear-stats-ajax-request', LANDINGPAGES_URLPATH . 'js/ajax.clearstats.js', array('jquery')); wp_localize_script('lp-admin-clear-stats-ajax-request', 'ajaxadmin', array('ajaxurl' => admin_url('admin-ajax.php'), 'lp_clear_nonce' => wp_create_nonce('lp-clear-nonce'))); // Add New and Edit Screens if ($hook == 'post-new.php' || $hook == 'post.php') { add_filter('wp_default_editor', 'lp_ab_testing_force_default_editor'); // force html view //admin.metaboxes.js - Template Selector - Media Uploader wp_enqueue_script('lp-js-metaboxes', LANDINGPAGES_URLPATH . 'js/admin/admin.metaboxes.js'); $template_data = lp_get_extension_data(); $template_data = json_encode($template_data); $template = get_post_meta($post->ID, 'lp-selected-template', true); $template = apply_filters('lp_selected_template', $template); $template = strtolower($template); $params = array('selected_template' => $template, 'templates' => $template_data); wp_localize_script('lp-js-metaboxes', 'data', $params); // Conditional TINYMCE for landing pages //wp_dequeue_script('jquery-tinymce'); //wp_enqueue_script('jquery-tinymce', LANDINGPAGES_URLPATH . 'js/libraries/tiny_mce/jquery.tinymce.js'); wp_enqueue_style('inbound-metaboxes', LANDINGPAGES_URLPATH . 'shared/metaboxes/inbound-metaboxes.css'); } if ($plugin_page === 'lp_global_settings') { wp_enqueue_script('lp-settings-js', LANDINGPAGES_URLPATH . 'js/admin/admin.global-settings.js'); } // Edit Screen if ($hook == 'post.php') { wp_enqueue_script('lp-post-edit-ui', LANDINGPAGES_URLPATH . 'js/admin/admin.post-edit.js'); wp_localize_script('lp-post-edit-ui', 'lp_post_edit_ui', array('ajaxurl' => admin_url('admin-ajax.php'), 'post_id' => $post->ID, 'wp_landing_page_meta_nonce' => wp_create_nonce('wp-landing-page-meta-nonce'), 'lp_template_nonce' => wp_create_nonce('lp-nonce'))); wp_enqueue_style('admin-post-edit-css', LANDINGPAGES_URLPATH . 'css/admin-post-edit.css'); wp_enqueue_script('jqueryui'); // jquery datepicker wp_enqueue_script('jquery-datepicker', LANDINGPAGES_URLPATH . 'js/libraries/jquery-datepicker/jquery.timepicker.min.js'); wp_enqueue_script('jquery-datepicker-base', LANDINGPAGES_URLPATH . 'js/libraries/jquery-datepicker/lib/base.js'); wp_enqueue_script('jquery-datepicker-datepair', LANDINGPAGES_URLPATH . 'js/libraries/jquery-datepicker/lib/datepair.js'); wp_localize_script('jquery-datepicker', 'jquery_datepicker', array('thispath' => LANDINGPAGES_URLPATH . 'js/libraries/jquery-datepicker/')); wp_enqueue_script('jquery-datepicker-functions', LANDINGPAGES_URLPATH . 'js/libraries/jquery-datepicker/picker_functions.js'); wp_enqueue_style('jquery-timepicker-css', LANDINGPAGES_URLPATH . 'js/libraries/jquery-datepicker/jquery.timepicker.css'); wp_enqueue_style('jquery-datepicker-base.css', LANDINGPAGES_URLPATH . 'js/libraries/jquery-datepicker/lib/base.css'); // New frontend editor if (isset($_GET['frontend']) && $_GET['frontend'] === 'true') { //show_admin_bar( false ); // doesnt work wp_enqueue_style('new-customizer-admin', LANDINGPAGES_URLPATH . 'css/new-customizer-admin.css'); wp_enqueue_script('new-customizer-admin', LANDINGPAGES_URLPATH . 'js/admin/new-customizer-admin.js'); } } // Add New Screen if ($hook == 'post-new.php') { // Create New Landing Jquery UI wp_enqueue_script('lp-js-create-new-lander', LANDINGPAGES_URLPATH . 'js/admin/admin.post-new.js', array('jquery'), '1.0', true); wp_localize_script('lp-js-create-new-lander', 'lp_post_new_ui', array('ajaxurl' => admin_url('admin-ajax.php'), 'post_id' => $post->ID, 'wp_landing_page_meta_nonce' => wp_create_nonce('lp_nonce'), 'LANDINGPAGES_URLPATH' => LANDINGPAGES_URLPATH)); wp_enqueue_style('lp-css-post-new', LANDINGPAGES_URLPATH . 'css/admin-post-new.css'); } // List Screen if ($screen->id == 'edit-landing-page') { wp_enqueue_script(array('jquery', 'editor', 'thickbox', 'media-upload')); wp_enqueue_script('landing-page-list', LANDINGPAGES_URLPATH . 'js/admin/admin.landing-page-list.js'); wp_enqueue_style('landing-page-list-css', LANDINGPAGES_URLPATH . 'css/admin-landing-page-list.css'); wp_enqueue_script('jqueryui'); wp_admin_css('thickbox'); add_thickbox(); } } else { if ($hook == 'post.php') { wp_enqueue_style('lp-ab-testing-admin-css', LANDINGPAGES_URLPATH . 'css/admin-ab-testing.css'); } } /* Requeue third party scripts */ if (is_array($store)) { foreach ($store as $handle) { wp_enqueue_script($handle); } } }
/** * generate metabox html from extended dataset */ public static function display_extended_metabox($post, $args) { $extension_data = lp_get_extension_data(); $key = $args['args']['key']; $lp_custom_fields = $extension_data[$key]['settings']; self::render_fields($key, $lp_custom_fields, $post); }