function customizer_load($wp_customize) { pl_add_customizer_classes(); // if ( $wp_customize->is_preview() && ! is_admin() ) { // add_action( 'wp_footer', array( $this, 'customize_preview' ), 21 ); // } $wp_customize->get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; $config = apply_filters('pl_platform_customizer_config', array()); /** * register the sections */ if (is_array($config) && !empty($config)) { foreach ($config as $id => $section) { /** Dont show in customizer if not meant for it... */ if (!$this->check_location($section)) { continue; } $priority = isset($section['priority']) ? $section['priority'] : 20; $section_config = array('title' => strip_tags($section['title']), 'priority' => $priority); $key = isset($section['key']) ? $section['key'] : pl_ui_key($section['title']); $wp_customize->add_section($section['key'], $section_config); foreach ($section['opts'] as $i => $o) { /** Dont show in customizer if not meant for it... */ if (!$this->check_location($o)) { continue; } $o['section'] = $section['key']; $o = $this->customizer_engine($o, $section); $handling = isset($o['handling']) ? $o['handling'] : array(); $handling = wp_parse_args($handling, array('default' => '', 'type' => 'option', 'capability' => 'edit_theme_options')); $wp_customize->add_setting($this->prepare_option($o['key']), $handling); if (isset($o['class'])) { $set = $o; unset($set['type']); $wp_customize->add_control(new $o['class']($wp_customize, $o['key'], $set)); } else { $wp_customize->add_control($this->prepare_option($o['key']), $o); } } } } }
/** * Main cards display function */ function cards($args = array()) { $search = isset($_GET['s']) ? esc_attr($_GET['s']) : ''; $current_nav_item = isset($_GET['navitem']) ? $_GET['navitem'] : ''; $args = wp_parse_args($args, array('hook' => '', 'navscheme' => array(), 'baseURL' => PL_Platform()->url(), 'sbitems' => array())); ?> <div class="pl-cards-ui" data-baseurl="<?php echo $args['baseURL']; ?> "> <div class="pl-store-head fix"> <h2 class="pl-store-title"></h2> <form class="search-form search-plugins" action="<?php echo admin_url('admin-post.php'); ?> " method="post"> <input type="hidden" name="action" value="storesearch" /> <label><span class="screen-reader-text">Search</span> <input class="wp-filter-search" label="search" type="text" name="s" placeholder="<?php _e('Search Extensions', 'pl-platform'); ?> " value="<?php echo $search; ?> "/> </label> <input type="submit" id="search-submit" class="button screen-reader-text" value="Search"> </form> </div> <div class="pl-cards-wrap fix"> <div class="pl-cards-nav"> <ul class="pl-filter-links"> <?php foreach ($args['navscheme'] as $type => $items) { $name = isset($items['name']) ? $items['name'] : pl_ui_key($type); unset($items['name']); ?> <lh><span class="hdng"><?php echo $name; ?> </span></lh> <?php foreach ($items as $cat => $details) { $navitem = $type . '_' . $cat; $class = $current_nav_item == $navitem ? 'current' : ''; $details['q']['navitem'] = $navitem; $url = add_query_arg($details['q'], $args['baseURL']); ?> <li><a href="<?php echo $url; ?> " class="<?php echo $class . ' ' . $navitem; ?> " title="<?php echo $details['title']; ?> "><?php echo $details['name']; ?> </a></li> <?php } ?> <?php } ?> </ul> <div class="card-nav-actions"> <?php if (!$this->platform->oauth->is_site_registered()) { ?> <p><a class="button button-primary" href="<?php echo PL_Platform()->url('account'); ?> "><i class="pl-icon pl-icon-plus"></i> Upgrade to Pro</a></p> <?php } ?> <p><a class="button button-refresh" href="<?php echo add_query_arg(array('refresh' => 1), $args['baseURL']); ?> "><i class="pl-icon pl-icon-refresh"></i> <?php _e('Refresh Data', 'pl-platform'); ?> </a></p> </div> </div> <div class="pl-cards" data-hook="<?php echo $args['hook']; ?> "> </div> </div> </div> <?php }
function get_page_slug_info($page_slug, $item = 'all') { $return = array(); $page_slug_fragments = explode('__', $page_slug); $groupID = $page_slug_fragments[0]; $typeID = isset($page_slug_fragments[1]) ? $page_slug_fragments[1] : ''; $metaID = isset($page_slug_fragments[2]) ? $page_slug_fragments[2] : ''; $termID = isset($page_slug_fragments[3]) ? $page_slug_fragments[3] : ''; $term_slug = $termID != '' && is_numeric($metaID) ? $termID : $metaID; $type_slug = $typeID != '' ? $typeID : $groupID; $defaults = array('url' => '', 'name' => pl_ui_key($type_slug), 'slug' => $page_slug, 'type' => $type_slug, 'term' => $term_slug); /** Single Posts, Pages, etc.. */ if ($groupID == 'single') { /* If a page ID is provided, we have a link */ $return['url'] = isset($metaID) ? get_permalink($metaID) : ''; if (is_numeric($metaID)) { $return['name'] = get_the_title($metaID) ? stripslashes(get_the_title($metaID)) : __('(No Title)', 'pl-platform'); if (get_option('show_on_front') == 'page' && get_option('page_on_front') == $metaID) { $return['url'] = home_url(); $return['name'] = sprintf(__('Home Page', 'pl-platform')); } } } elseif ($groupID == 'archive') { if ($typeID == 'post') { $return['name'] = pl_ui_key($metaID); } if ($metaID == 'blog') { if (get_option('show_on_front') == 'page' && get_option('page_for_posts')) { $return['url'] = get_permalink(get_option('page_for_posts')); } else { $return['url'] = home_url(); } } elseif ($metaID == 'date') { $return['url'] = home_url('?m=' . date('Y')); } elseif ($metaID == 'search') { $return['url'] = home_url('?s=and'); } elseif ($metaID == 'category') { /* Specific Category ID provided */ if (isset($termID) && is_numeric($termID)) { $term = get_term($termID, 'category'); $return['name'] = $term->name ? stripslashes($term->name) : '(No Title)'; $return['url'] = home_url('?cat=' . $termID); } } elseif ($metaID == 'author') { /* Author ID Provided */ if (isset($termID) && is_numeric($termID)) { $user_data = get_userdata($termID); $return['name'] = stripslashes($user_data->display_name); } else { $current_user = wp_get_current_user(); $termID = $current_user->ID; } $return['url'] = home_url('?author=' . $termID); } elseif (is_object(get_post_type_object($typeID))) { $PT = get_post_type_object($typeID); $return['name'] = $PT->labels->name; $return['url'] = get_post_type_archive_link($typeID); if (!empty($metaID) && false !== strpos($metaID, 'search')) { $return['name'] = __('Search: ', 'pl-platform') . $return['name']; $return['url'] = $return['url'] . '?s=and&post_type=' . $typeID; } elseif (!empty($termID) && is_numeric($termID)) { $term = get_term($termID, $metaID); $return['name'] = $term->name; $return['url'] = get_term_link($termID, $metaID); } } elseif ($typeID == 'taxonomy' || $metaID == 'post_tag' || $metaID == 'post_format') { if ($typeID == 'taxonomy') { $return['name'] = pl_ui_key($typeID); $return['type'] = $metaID; } if ($metaID != '') { $taxonomy = get_taxonomy($metaID); $return['name'] = $taxonomy->labels->singular_name ? stripslashes($taxonomy->labels->singular_name) : '(No Title)'; } /* Term Provided */ if (!empty($termID)) { if (is_numeric($termID)) { $termID = (int) $termID; } $term = get_term($termID, $metaID); $return = array('url' => get_term_link($termID, $metaID), 'name' => isset($term->name) ? $term->name : '(No Title)', 'type' => $typeID); } } } elseif ($typeID == 'four04') { $return['name'] = '404 Error Page'; $return['url'] = home_url('set404-' . rand(100, 99999)); } $return = wp_parse_args($return, $defaults); return $item != 'all' ? $return[$item] : $return; }
/** * Add main WP menus */ function add_wp_menus() { /** Main Menu Item */ add_menu_page('PageLines', 'PageLines', $this->config['priv'], $this->page_slug('settings'), $this->config['ui'], false, '2.4'); $menus = array('settings' => true, 'extend' => is_super_admin() ? true : false, 'account' => is_super_admin() ? true : false); // loop through items and add menus if $allowed == true foreach (apply_filters('pl_platform_menus', $menus) as $slug => $allowed) { if ($allowed) { add_submenu_page($this->page_slug('settings'), pl_ui_key($slug), pl_ui_key($slug), $this->config['priv'], $this->page_slug($slug), $this->config['ui']); } } }
/** * Return the option array information * for a commonly used option type */ function pl_std_opt($type, $additions = array()) { if ('image' == $type) { $o = array('type' => 'image_upload'); } elseif ('icons' == $type) { $o = array('type' => 'textarea', 'place' => "facebook http://facebook.com/pagelines\ntwitter http://twitter.com/pagelines", 'ref' => __('<p>Add linked icons using slug/url pairs.</p><p>Add each on a new line. <br/><strong>Format:</strong><br/> [icon slug] [link url]</p><p/><strong>Example:</strong><br/> facebook http://facebook.com/you</p> <p>Use <a href="https://fortawesome.github.io/Font-Awesome/icons/">Font Awesome</a> to get the icon slug.</p>', 'pl-platform')); } elseif ('icon' == $type) { $o = array('type' => 'select_icon', 'default' => 'ok'); } elseif ('title' == $type) { $o = array('type' => 'text', 'default' => 'Hello.'); } elseif ('text' == $type) { $o = array('type' => 'richtext', 'default' => 'Just some text.'); } elseif ('html' == $type) { $o = array('type' => 'textarea', 'default' => '<p>Just some html.</p>'); } elseif ('link' == $type || 'header' == $type) { $o = array('type' => 'text'); } elseif ('logo' == $type) { $o = array('type' => 'image_upload', 'has_alt' => true); } elseif ('menu' == $type) { $o = array('type' => 'select_menu', 'label' => __('Select Menu', 'pl-platform')); } elseif ('search' == $type) { $o = array('type' => 'check', 'label' => __('Show Search?', 'pl-platform')); } elseif ('button' == $type) { $key = isset($additions['key']) ? $additions['key'] : $type; $o = array('title' => __('Button / Link', 'pl-platform'), 'type' => 'multi', 'stylize' => 'button-config', 'opts' => pl_button_link_options($key, $additions)); } elseif ('background_image' == $type) { $o = array('type' => 'image_upload'); } elseif ('background_color' == $type) { $o = array('type' => 'color'); } elseif ('columns' == $type) { $o = array('type' => 'select', 'opts' => array('2' => array('name' => __('2 of 12 Columns', 'pl-platform')), '3' => array('name' => __('3 of 12 Columns', 'pl-platform')), '4' => array('name' => __('4 of 12 Columns', 'pl-platform')), '6' => array('name' => __('6 of 12 Columns', 'pl-platform')), '12' => array('name' => __('12 of 12 Columns', 'pl-platform')))); } elseif ('posts_per_page' == $type) { $o = array('type' => 'count_select', 'count_start' => 1, 'count_number' => 36); } elseif ('text_alignment' == $type) { $o = array('type' => 'radio', 'opts' => array(array('txt' => '<i class="pl-icon pl-icon-minus"></i>', 'val' => ''), array('txt' => '<i class="pl-icon pl-icon-align-left"></i>', 'val' => 'pl-alignment-left'), array('txt' => '<i class="pl-icon pl-icon-align-center"></i>', 'val' => 'pl-alignment-center'), array('txt' => '<i class="pl-icon pl-icon-align-right"></i>', 'val' => 'pl-alignment-right'))); } elseif ('section_alignment' == $type) { $o = array('type' => 'radio', 'opts' => array(array('txt' => '<i class="pl-icon pl-icon-minus"></i>', 'val' => ''), array('txt' => '<i class="pl-icon pl-icon-long-arrow-left"></i>', 'val' => 'pl-section-left'), array('txt' => '<i class="pl-icon pl-icon-arrows-h"></i>', 'val' => 'pl-section-center'), array('txt' => '<i class="pl-icon pl-icon-long-arrow-right"></i>', 'val' => 'pl-section-right'))); } elseif ('scheme' == $type) { $o = array('label' => __('Text/Element Color Scheme', 'pl-platform'), 'type' => 'select', 'default' => 'pl-scheme-default', 'opts' => array('pl-scheme-default' => array('name' => __('Default', 'pl-platform')), 'pl-scheme-light' => array('name' => __('White', 'pl-platform')), 'pl-scheme-dark' => array('name' => __('Black', 'pl-platform'))), 'help' => 'Note: This will override link colors if set.'); } $o = wp_parse_args($additions, $o); $key = isset($o['key']) ? $o['key'] : $type; $o = wp_parse_args($o, array('key' => $key, 'label' => pl_ui_key($key))); return $o; }