本文整理汇总了PHP中get_page_template_slug函数的典型用法代码示例。如果您正苦于以下问题:PHP get_page_template_slug函数的具体用法?PHP get_page_template_slug怎么用?PHP get_page_template_slug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_page_template_slug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_content
public function render_content()
{
$llorix_one_all_pages_array = array();
// new array with all pages
$llorix_one_all_pages = get_pages();
// get all pages
if (!empty($llorix_one_all_pages)) {
$llorix_one_all_pages_array[0] = "-- Select --";
foreach ($llorix_one_all_pages as $llorix_one_page) {
if (!empty($llorix_one_page->ID) && !empty($llorix_one_page->post_title)) {
$llorix_one_all_pages_array[$llorix_one_page->ID] = $llorix_one_page->post_title;
}
}
}
if (!empty($llorix_one_all_pages_array)) {
// change the frontpage control with the new array
echo '<label>';
echo '<span class="customize-control-title">' . esc_html($this->label) . '</span>';
echo '<select data-customize-setting-link="page_on_front" name="_customize-dropdown-pages-page_on_front" id="_customize-dropdown-pages-page_on_front">';
foreach ($llorix_one_all_pages_array as $llorix_one_all_pages_array_k => $llorix_one_all_pages_array_v) {
$llorix_one_page_template = get_page_template_slug($llorix_one_all_pages_array_k);
if (!empty($llorix_one_page_template)) {
echo '<option value="' . $llorix_one_all_pages_array_k . '" template="' . $llorix_one_page_template . '">' . $llorix_one_all_pages_array_v . '</option>';
} else {
echo '<option value="' . $llorix_one_all_pages_array_k . '" template="default">' . $llorix_one_all_pages_array_v . '</option>';
}
}
echo '</select>';
echo '</label>';
}
}
示例2: display
public function display($post)
{
if (!empty($this->settings['page_template'])) {
//echo $this->settings['page_template'];
$page_template = get_page_template_slug(get_queried_object_id());
if ($page_template != $this->settings['page_template']) {
return false;
}
}
$this->postID = $post->ID;
wp_nonce_field($this->settings['id'], TF . '_' . $this->settings['id'] . '_nonce');
if (!empty($this->settings['desc'])) {
?>
<p class='description'><?php
echo $this->settings['desc'];
?>
</p><?php
}
?>
<table class="form-table tf-form-table">
<tbody>
<?php
foreach ($this->options as $option) {
$option->display();
}
?>
</tbody>
</table>
<?php
}
示例3: mp_stacks_remove_hentry_from_stack_page_templates
/**
* Remove "hentry" from page post_class if the page template is "Optimize for MP Stacks"
*
* @since 1.0
* @return void
*/
function mp_stacks_remove_hentry_from_stack_page_templates($classes)
{
global $post;
$class_name_counter = 0;
//Loop through each class name
foreach ($classes as $class_name) {
$page_template_slug = get_page_template_slug($post->ID);
//If one of the class names is hentry
if ($class_name == 'hentry') {
//If we are using the mp-stacks-page-template
if (get_page_template_slug($post->ID) == 'mp-stacks-page-template.php') {
//Remove hentry from the classes array
$classes[$class_name_counter] = '';
} else {
if (empty($page_template_slug)) {
//Check the title of the default page template - This filter: https://core.trac.wordpress.org/ticket/27178
$default_page_template_title = apply_filters('default_page_template_title', __('Default Template'));
//If the default page template's title includes the word "Stack"
if (strpos($default_page_template_title, 'Stack') !== false) {
//Remove hentry from the classes array
$classes[$class_name_counter] = '';
}
}
}
}
$class_name_counter = $class_name_counter + 1;
}
return $classes;
}
示例4: menu_endpoint
function menu_endpoint($data)
{
$args = array('order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, 'update_post_term_cache' => false);
$menu = wp_get_nav_menu_items($data['id'], $args);
$fallback_menu = wp_get_nav_menu_items('2', $args);
$menu = json_decode(json_encode($menu), true);
$fallback_menu = json_decode(json_encode($fallback_menu), true);
if ($menu != false) {
$menu = $menu;
} else {
$menu = $fallback_menu;
}
for ($i = 0; $i < sizeof($menu); $i++) {
unset($menu[$i]['post_password']);
unset($menu[$i]['post_name']);
unset($menu[$i]['to_ping']);
unset($menu[$i]['pinged']);
unset($menu[$i]['post_modified']);
unset($menu[$i]['post_modified_gmt']);
unset($menu[$i]['post_content_filtered']);
unset($menu[$i]['post_parent']);
unset($menu[$i]['post_mime_type']);
unset($menu[$i]['comment_count']);
unset($menu[$i]['filter']);
unset($menu[$i]['object']);
unset($menu[$i]['type']);
unset($menu[$i]['post_date']);
unset($menu[$i]['post_date_gmt']);
$menu[$i]['template'] = split('.php', get_page_template_slug($menu[$i]['object_id']))[0];
}
//if the id would return nothing - return the default menu
return $menu;
}
示例5: kt_metabox_show_on_kt_template
function kt_metabox_show_on_kt_template($display, $meta_box)
{
if ('kt-template' !== $meta_box['show_on']['key']) {
return $display;
}
// Get the current ID
if (isset($_GET['post'])) {
$post_id = $_GET['post'];
} elseif (isset($_POST['post_ID'])) {
$post_id = $_POST['post_ID'];
}
if (!isset($post_id)) {
return false;
}
$template_name = get_page_template_slug($post_id);
$template_name = substr($template_name, 0, -4);
// If value isn't an array, turn it into one
$meta_box['show_on']['value'] = !is_array($meta_box['show_on']['value']) ? array($meta_box['show_on']['value']) : $meta_box['show_on']['value'];
// See if there's a match
if (in_array($template_name, $meta_box['show_on']['value'])) {
return false;
} else {
return true;
}
}
示例6: get_hidden_layouts
public function get_hidden_layouts($field)
{
global $wpdb, $post;
if (!isset($field["parent_layout"])) {
return;
}
if (is_object($post) && isset($post->ID)) {
$post_id = $post->ID;
} else {
return;
}
$template = get_page_template_slug($post_id);
$content = $wpdb->get_var($wpdb->prepare("SELECT post_content FROM {$wpdb->posts} WHERE post_name = %s", $field["parent"]));
$content = unserialize($content);
$hides = array();
if (is_array($content) && isset($content["layouts"])) {
foreach ($content["layouts"] as $layout) {
if (!isset($layout["visibility"])) {
continue;
}
$visibility = array_filter(explode(" ", str_replace(",", " ", $layout["visibility"])));
if (in_array($template, $visibility)) {
$hides[$layout["name"]] = $layout["visibility"];
}
}
}
foreach ($hides as $key => $hide) {
$this->css[] = "div.acf-fc-popup a[data-layout='" . $key . "'] { display: none; }\n";
}
}
示例7: conditional_scripts
public function conditional_scripts()
{
global $PhoenixData, $template;
$what_template = get_page_template_slug();
if ($what_template == 'template-portfolio.php' || basename($template) == 'single-' . THEME_SLUG . '_portfolio.php') {
$cubeportfolio = array('inlineError' => __("Error! Please refresh the page!", 'grandway'), 'moreLoading' => __("Loading...", 'grandway'), 'moreNoMore' => __("No More Works", 'grandway'));
$port_layout = isset($PhoenixData['port_layout']) ? $PhoenixData['port_layout'] : '2-cols';
switch ($port_layout) {
case '2-cols':
$cube_js = 'portfolio-2';
break;
case '3-cols':
$cube_js = 'portfolio-3';
break;
case '4-cols':
$cube_js = 'portfolio-4';
break;
case 'full':
$cube_js = 'portfolio-fullwidth';
break;
default:
$cube_js = 'portfolio-2';
break;
}
wp_register_script(THEME_SLUG . '-portfolio', THEME_URI . '/assets/js/' . $cube_js . '.js', array('jquery'), '1.0.0', true);
wp_enqueue_script(THEME_SLUG . '-portfolio');
wp_localize_script(THEME_SLUG . '-jquery.cubeportfolio', 'portSetts', $cubeportfolio);
}
if (is_singular(THEME_SLUG . '_portfolio')) {
wp_dequeue_script(THEME_SLUG . '-portfolio');
wp_enqueue_script(THEME_SLUG . '-portfolio-single', THEME_URI . '/assets/js/portfolio-3.js', array('jquery'), '1.0.0', true);
}
}
示例8: wptgbs_link_to_id_filter
function wptgbs_link_to_id_filter($atts, $item, $args)
{
if (get_page_template_slug() == 'home.php') {
// $atts['href'] = '#'.get_post_type($item->object_id).'-'.$item->object_id;
$atts['href'] = '#post-' . $item->object_id;
}
return $atts;
}
示例9: get_current_template
/**
* Get current template
*
* @return string
*/
function get_current_template()
{
// Get page id for all pages and detail pages
global $post;
// $page_id = (isset($post->detail_id)) ? $post->detail_id: get_queried_object_id();
$page_id = isset($post->ID) ? $post->ID : get_queried_object_id();
return basename(get_page_template_slug($page_id), '.php');
}
示例10: quest_is_pb_template
/**
* Is the current page a Page Builder Page ?
*
* @since 1.3.0
* @return string html menu
*/
function quest_is_pb_template()
{
global $post;
if ($post && !is_search() && get_page_template_slug($post->ID) === 'page-builder.php') {
return true;
}
return false;
}
示例11: rs_theme_show_if_full_width
function rs_theme_show_if_full_width($cmb)
{
// Show this metabox if it's full width
if ('page-templates/template-fullwidth.php' == get_page_template_slug($cmb->object_id)) {
return true;
}
return false;
}
示例12: addMetaBox
public function addMetaBox()
{
$templates = get_page_templates();
$template = get_page_template_slug();
if ($this->pageTemplate == 'any' || $templates[$this->pageTemplate] == $template) {
add_meta_box($this->id, $this->title, [$this->metaTemplate, 'getHtml'], $this->type, $this->context, $this->priority);
}
}
示例13: teaberry_add_mce_body_tags
/**
* add body tags to mce editor based on current template
*/
function teaberry_add_mce_body_tags($classes)
{
global $post;
$template = get_page_template_slug($post->ID);
if ($template == 'page-templates/full-width.php') {
$classes['body_class'] = 'full-width';
}
return $classes;
}
示例14: setCurrentPostInformation
private function setCurrentPostInformation()
{
//Parse our WordPress template formatting to get another potential match for content.
$this->currentPostInfo = array('id' => get_the_ID(), 'title' => get_the_title(), 'slug' => basename(get_permalink()), 'templateType' => '');
if (is_page_template()) {
$rawSlug = preg_match('/(?<=\\/).*?(?=-)/', get_page_template_slug(), $matchedSlug);
$this->currentPostInfo['templateType'] = $matchedSlug[0] . "-section-sidebar";
}
}
示例15: filter_by_template_page
/**
* Filter that allow to change the sizes on pages that uses custom
* page templates.
*
* @since 1.1.0
*
* @param array $sizes The images sizes.
* @param int $id The id of the post, page or custom post type.
* @return return the array with the new sizes.
*/
public function filter_by_template_page($sizes, $id = 0)
{
$template = get_page_template_slug($id);
if (empty($template)) {
return $sizes;
}
$template_name = Formatter::to_filter_format($template);
return apply_filters(Formatter::katana_filter($template_name), $sizes);
}