• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_page_by_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_page_by_path函数的典型用法代码示例。如果您正苦于以下问题:PHP get_page_by_path函数的具体用法?PHP get_page_by_path怎么用?PHP get_page_by_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_page_by_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: url_shortcode

function url_shortcode($atts)
{
    // Attributes
    extract(shortcode_atts(array('type' => '', 'id' => '0', 'path' => '', 'title' => '', 'action' => '', 'class' => ''), $atts));
    if (!$id && !$path && !$title && !$action) {
        return home_url();
    } else {
        $page_id = 0;
        if ($id && is_numeric($id)) {
            $page_id = $id;
        }
        if ($path != '') {
            $page_id = get_page_by_path($path);
        }
        if ($title != '') {
            $page_id = get_page_by_title($title);
        }
        if ($action != '') {
            if ($action == 'logout') {
                return wp_logout_url();
            }
        }
        if ($page_id) {
            return get_page_link($page_id);
        } else {
            return null;
        }
    }
}
开发者ID:sgssandhu,项目名称:aione-tools,代码行数:29,代码来源:general.php


示例2: by_path

 /**
  * Gets a WordPress® post by path; instead of by ID.
  *
  * @param string $path A URL path (ex: `/sample-page/`, `/sample-page`, `sample-page`).
  *    This also works with sub-pages (ex: `/parent-page/sub-page/`).
  *    Also with post type prefixes (ex: `/post/hello-world/`).
  *    Also with pagination (ex: `/post/hello-world/page/2`).
  *
  * @param array  $exclude_types Optional. Defaults to `array('revision', 'nav_menu_item')`.
  *    We will NOT search for these post types. Pass an empty array to search all post types.
  *    Important to note... it is NOT possible to exclude the `attachment` type;
  *    because {@link \get_page_by_path()} always searches this type.
  *
  * @return null|\WP_Post A WP_Post object instance if found; else NULL.
  *
  * @throws exception If invalid types are passed through arguments list.
  *
  * @see http://codex.wordpress.org/Function_Reference/get_page_by_path
  *    NOTE: This supports MORE than just pages; even though the function name implies otherwise.
  */
 public function by_path($path, $exclude_types = array('revision', 'nav_menu_item'))
 {
     $this->check_arg_types('string', 'array', func_get_args());
     $path = trim($path, '/');
     // Trim all slashes.
     $path = preg_replace($this->©url->regex_wp_pagination_page(), '', $path);
     if ($path && $path !== '/') {
         foreach (get_post_types() as $_type) {
             if (!in_array($_type, $exclude_types, TRUE)) {
                 $_type_slug = $_type;
                 // Default slug.
                 $_type_specs = get_post_type_object($_type);
                 if ($this->©array->is_not_empty($_type_specs->rewrite)) {
                     if ($this->©string->is_not_empty($_type_specs->rewrite['slug'])) {
                         $_type_slug = $_type_specs->rewrite['slug'];
                     }
                 }
                 if ($_path = preg_replace('/^' . preg_quote($_type_slug, '/') . '\\//', '', $path)) {
                     if ($post = get_page_by_path($_path, OBJECT, $_type)) {
                         return $post;
                     }
                 }
             }
         }
     }
     unset($_type, $_type_specs, $_type_slug);
     return NULL;
     // Default return value.
 }
开发者ID:panvagenas,项目名称:x-related-posts,代码行数:49,代码来源:posts.php


示例3: form

    function form($instance)
    {
        $home = get_page_by_path('home');
        $home_text = get_post_meta($home->ID, 'home_text_widget', true);
        if (empty($home_text)) {
            $home_text['home_text_title'] = __('Titel');
            $home_text['home_text_body'] = '';
        }
        ?>
	 <p>
	 	<label for="home_text_title">Titel</label>
	 	<input id="home_text_title" name="home_text_title" value="<?php 
        echo $home_text['home_text_title'];
        ?>
" style="width:100%;" />
	 </p>
	 <p>
	 	<label for="home_text_body">Body</label>
	 	<textarea id="home_text_body" name="home_text_body" style="width:100%;height:80px;"><?php 
        echo $home_text['home_text_body'];
        ?>
</textarea>
	 </p>
    <?php 
    }
开发者ID:chefduweb,项目名称:cuisine,代码行数:25,代码来源:widget-home-text.php


示例4: print_sibiling_pages

function print_sibiling_pages($post)
{
    $slug_parts = explode('-', $post->post_name);
    if (count($slug_parts) != 2) {
        return;
    }
    $page_num = intval($slug_parts[1]);
    if ($page_num <= 0) {
        return;
    }
    echo '<div class="story-pageing">';
    if ($page_num > 1) {
        $back_slug = $slug_parts[0] . '-' . ($page_num - 1);
        $back_page = get_posts(array('name' => $back_slug, 'post_type' => 'page'));
        if (count($back_page) > 0) {
            echo '<div class="story-back"><a href="' . get_permalink(get_page_by_path($back_slug)) . '">Read Previous Story</a></div>';
        }
    }
    $next_slug = $slug_parts[0] . '-' . ($page_num + 1);
    $next_page = get_posts(array('name' => $next_slug, 'post_type' => 'page'));
    if (count($next_page) > 0) {
        echo '<div class="story-next"><a href="' . get_permalink(get_page_by_path($next_slug)) . '">Read Next Story</a></div>';
    }
    echo '</div>';
}
开发者ID:shaderzak,项目名称:fhc-armenia,代码行数:25,代码来源:paged-stories.php


示例5: registerUser

 /**
  * ユーザー登録処理
  *
  */
 public function registerUser()
 {
     // 新規ユーザーデータを取得する
     $this->user = $this->clearUser();
     if (isset($_POST['nonce'])) {
         // エラーなら処理を中止する
         if ($this->errcode = $this->_illegalInput()) {
             return;
         }
         if ($_POST['action'] === 'confirm' && $this->_normalize()) {
             // ユーザー新規登録
             if (!$this->_newUser()) {
                 $this->errcode = 'FAILED_INSERT';
                 return;
             }
             // 登録完了メール送信
             if (!$this->_sendMail()) {
                 $this->errcode = 'FAILED_SENDING';
                 return;
             }
             // 登録完了リダイレクト表示
             $url = get_permalink(get_page_by_path(self::PAGE_THANKS));
             $redirect = add_query_arg(array('action' => 'registered', 'nonce' => wp_create_nonce(__CLASS__)), $url);
             wp_redirect($redirect);
             exit;
         }
     }
 }
开发者ID:pcdaiko,项目名称:mtsbase,代码行数:32,代码来源:mtssb-register.php


示例6: shortcode

 /**
  * Creates the shortcode for the plugin.
  *
  * @since 2.0.0
  *
  * @global object $post The current post object.
  *
  * @param array $atts Array of shortcode attributes.
  * @return string     The optin output.
  */
 public function shortcode($atts)
 {
     global $post;
     $optin_id = false;
     if (isset($atts['id'])) {
         $optin_id = (int) $atts['id'];
     } else {
         if (isset($atts['slug'])) {
             $optin = get_page_by_path($atts['slug'], OBJECT, 'optin');
             if ($optin) {
                 $optin_id = $optin->ID;
             }
         } else {
             // A custom attribute must have been passed. Allow it to be filtered to grab the optin ID from a custom source.
             $optin_id = apply_filters('optin_monster_custom_optin_id', false, $atts, $post);
         }
     }
     // Allow the optin ID to be filtered before it is stored and used to create the optin output.
     $optin_id = apply_filters('optin_monster_pre_optin_id', $optin_id, $atts, $post);
     // If there is no optin, do nothing.
     if (!$optin_id) {
         return false;
     }
     // If we are in a preview state, the optin needs to match the one requested, otherwise return false.
     if (Optin_Monster_Output::get_instance()->is_preview()) {
         if (Optin_Monster_Output::get_instance()->optin_id && Optin_Monster_Output::get_instance()->optin_id !== $optin_id || !empty(Optin_Monster_Output::get_instance()->data[$optin_id])) {
             return false;
         }
     }
     // Return the output.
     return Optin_Monster_Output::get_instance()->get_optin_monster($optin_id);
 }
开发者ID:venturepact,项目名称:blog,代码行数:42,代码来源:shortcode.php


示例7: install

 /**
  * Install WP Job Manager
  */
 public static function install()
 {
     global $wpdb;
     self::init_user_roles();
     self::default_terms();
     self::schedule_cron();
     // Redirect to setup screen for new installs
     if (!get_option('wp_job_manager_version')) {
         set_transient('_job_manager_activation_redirect', 1, HOUR_IN_SECONDS);
     }
     // Update featured posts ordering
     if (version_compare(get_option('wp_job_manager_version', JOB_MANAGER_VERSION), '1.22.0', '<')) {
         $wpdb->query("UPDATE {$wpdb->posts} p SET p.menu_order = 0 WHERE p.post_type='job_listing';");
         $wpdb->query("UPDATE {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id SET p.menu_order = -1 WHERE pm.meta_key = '_featured' AND pm.meta_value='1' AND p.post_type='job_listing';");
     }
     // Update legacy options
     if (false === get_option('job_manager_submit_job_form_page_id', false) && get_option('job_manager_submit_page_slug')) {
         $page_id = get_page_by_path(get_option('job_manager_submit_page_slug'))->ID;
         update_option('job_manager_submit_job_form_page_id', $page_id);
     }
     if (false === get_option('job_manager_job_dashboard_page_id', false) && get_option('job_manager_job_dashboard_page_slug')) {
         $page_id = get_page_by_path(get_option('job_manager_job_dashboard_page_slug'))->ID;
         update_option('job_manager_job_dashboard_page_id', $page_id);
     }
     delete_transient('wp_job_manager_addons_html');
     update_option('wp_job_manager_version', JOB_MANAGER_VERSION);
 }
开发者ID:vinodhip,项目名称:Function-22-Website,代码行数:30,代码来源:class-wp-job-manager-install.php


示例8: __construct

 /**
  * __construct function.
  */
 public function __construct()
 {
     // Define constants
     define('JOB_MANAGER_ALERTS_VERSION', '1.3.14');
     define('JOB_MANAGER_ALERTS_PLUGIN_DIR', untrailingslashit(plugin_dir_path(__FILE__)));
     define('JOB_MANAGER_ALERTS_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
     // Includes
     include 'includes/class-wp-job-manager-alerts-shortcodes.php';
     include 'includes/class-wp-job-manager-alerts-post-types.php';
     include 'includes/class-wp-job-manager-alerts-notifier.php';
     // Init classes
     $this->post_types = new WP_Job_Manager_Alerts_Post_Types();
     // Add actions
     add_action('init', array($this, 'init'), 12);
     add_action('wp_enqueue_scripts', array($this, 'frontend_scripts'));
     add_filter('job_manager_settings', array($this, 'settings'));
     add_filter('job_manager_job_filters_showing_jobs_links', array($this, 'alert_link'), 10, 2);
     add_action('single_job_listing_end', array($this, 'single_alert_link'));
     // Update legacy options
     if (false === get_option('job_manager_alerts_page_id', false) && get_option('job_manager_alerts_page_slug')) {
         $page_id = get_page_by_path(get_option('job_manager_alerts_page_slug'))->ID;
         update_option('job_manager_alerts_page_id', $page_id);
     }
     // Init updates
     $this->init_updates(__FILE__);
 }
开发者ID:sabdev1,项目名称:sabstaff,代码行数:29,代码来源:wp-job-manager-alerts.php


示例9: embedPatreonContent

 public function embedPatreonContent($args)
 {
     /* example shortcode [patreon_content slug="test-example"]
     
     		/* check if shortcode has slug parameter */
     if (isset($args['slug'])) {
         /* get patreon-content post with matching url slug */
         $patreon_content = get_page_by_path($args['slug'], OBJECT, 'patreon-content');
         if ($patreon_content == false) {
             return 'Patreon content not found.';
         }
         $patreon_level = get_post_meta($patreon_content->ID, 'patreon-level', true);
         if ($patreon_level == 0) {
             return $patreon_content->post_content;
         }
         $user_patronage = Patreon_Wordpress::getUserPatronage();
         if ($user_patronage != false) {
             if (is_numeric($patreon_level) && $user_patronage >= $patreon_level * 100) {
                 return $patreon_content->post_content;
             }
         }
         if (isset($args['youtube_id']) && isset($args['youtube_width']) && is_numeric($args['youtube_width']) && isset($args['youtube_height']) && is_numeric($args['youtube_height'])) {
             return '<iframe width="' . $args['youtube_width'] . '" height="' . $args['youtube_height'] . '" src="https://www.youtube.com/embed/' . $args['youtube_id'] . '?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>';
         } else {
             return self::displayPatreonCampaignBanner();
         }
     }
 }
开发者ID:bigt11,项目名称:patreon-wordpress,代码行数:28,代码来源:patreon_frontend.php


示例10: getArchive

 function getArchive()
 {
     $page = get_page_by_path($_SERVER['REQUEST_URI']);
     if (!is_null($page)) {
         return !empty($title = trim(\get_post_meta($page->ID, 'quan_meta_title', true))) ? $title : '';
     }
 }
开发者ID:alpipego,项目名称:wp-quan-postmeta,代码行数:7,代码来源:Title.php


示例11: form

    function form($instance)
    {
        $contact = get_page_by_path('contact');
        $contact_info = get_post_meta($contact->ID, 'contact_info_widget', true);
        if (empty($contact_info)) {
            $contact_info['contact_info_title'] = __('Titel');
            $contact_info['contact_info_body'] = '';
        }
        ?>
	 <p>
	 	<label for="contact_info_title">Titel</label>
	 	<input id="contact_info_title" name="contact_info_title" value="<?php 
        echo $contact_info['contact_info_title'];
        ?>
" style="width:100%;" />
	 </p>
	 <p>
	 	<label for="contact_info_body">Body</label>
	 	<textarea id="contact_info_body" name="contact_info_body" style="width:100%;height:80px;"><?php 
        echo $contact_info['contact_info_body'];
        ?>
</textarea>
	 </p>
    <?php 
    }
开发者ID:chefduweb,项目名称:cuisine,代码行数:25,代码来源:widget-contact-info.php


示例12: getArchive

 function getArchive()
 {
     $page = get_page_by_path($_SERVER['REQUEST_URI']);
     if (!is_null($page)) {
         return !empty($description = trim(\get_post_meta($page->ID, 'quan_meta_description', true))) ? $description : false;
     }
 }
开发者ID:alpipego,项目名称:wp-quan-postmeta,代码行数:7,代码来源:Description.php


示例13: index

 public function index($category_slug, $post_slug)
 {
     $post = get_page_by_path($post_slug, OBJECT, 'post');
     $post = new TimberPost($post->ID);
     $canonical_url = $post->catfish_importer_url;
     return $this->client->getSubmissionStatus(get_field('instant_articles_status_id', $post));
 }
开发者ID:shortlist-digital,项目名称:agreable-instant-articles-plugin,代码行数:7,代码来源:StatusController.php


示例14: old_wp_login_redirect

function old_wp_login_redirect()
{
    if (!is_user_logged_in() && in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) && get_page_by_path('login') != NULL) {
        wp_redirect(get_site_url() . '/login/', $status);
        die;
    }
}
开发者ID:evinw,项目名称:project_gdent,代码行数:7,代码来源:lockdown.php


示例15: add_rewrite_rules

 public static function add_rewrite_rules($rules)
 {
     //Get taxonomies
     $taxonomies = get_taxonomies();
     $blog_prefix = '';
     $endpoint = Slash_Edit::get_instance()->get_endpoint();
     if (is_multisite() && !is_subdomain_install() && is_main_site()) {
         /* stolen from /wp-admin/options-permalink.php */
         $blog_prefix = 'blog/';
     }
     $exclude = array('category', 'post_tag', 'nav_menu', 'link_category', 'post_format');
     foreach ($taxonomies as $key => $taxonomy) {
         if (in_array($key, $exclude)) {
             continue;
         }
         $rules["{$blog_prefix}{$key}/([^/]+)/{$endpoint}(/(.*))?/?\$"] = 'index.php?' . $key . '=$matches[1]&' . $endpoint . '=$matches[3]';
     }
     //Add home_url/edit to rewrites
     $add_frontpage_edit_rules = false;
     if (!get_page_by_path($endpoint)) {
         $add_frontpage_edit_rules = true;
     } else {
         $page = get_page_by_path($endpoint);
         if (is_a($page, 'WP_Post') && $page->post_status != 'publish') {
             $add_frontpage_edit_rules = true;
         }
     }
     if ($add_frontpage_edit_rules) {
         $edit_array_rule = array("{$endpoint}/?\$" => 'index.php?' . $endpoint . '=frontpage');
         $rules = $edit_array_rule + $rules;
     }
     return $rules;
 }
开发者ID:sebjon-bytbil,项目名称:BytBil-Hemsida,代码行数:33,代码来源:slash-edit.php


示例16: demo_content_starterkit_frontpage

function demo_content_starterkit_frontpage()
{
    $page = 'wine';
    $slug = get_page_by_path('home-pages/' . $page) ? 'home-pages/' . $page : $page;
    return $slug;
    // slug
}
开发者ID:ArnaudGuillou,项目名称:SiteESBVolley,代码行数:7,代码来源:demo-extras.php


示例17: pageParam

 protected function pageParam($params)
 {
     global $post;
     $name = array_shift($params);
     $path = get_page_uri($post->ID) . '/' . $name;
     return get_page_by_path($path);
 }
开发者ID:elpadi,项目名称:wordpress-library,代码行数:7,代码来源:TilesInfo.php


示例18: handle_request

 /**
  * Check if the path requested matches an assigned index page.
  *
  * Also checks for date and pagination parameters.
  *
  * @since 1.2.0 Added check to make sure post type currently exists.
  * @since 1.0.0
  *
  * @param WP $wp The WP request object.
  */
 public static function handle_request(\WP $wp)
 {
     $qv =& $wp->query_vars;
     // Abort if a pagename wasn't matched at all
     if (!isset($qv['pagename'])) {
         return;
     }
     // Build a RegExp to capture a page with date/paged arguments
     $pattern = '(.+?)' . '(?:/([0-9]{4})' . '(?:/([0-9]{2})' . '(?:/([0-9]{2}))?' . ')?' . ')?' . '(?:/page/([0-9]+))?' . '/?$';
     // Proceed if the pattern checks out
     if (preg_match("#{$pattern}#", $wp->request, $matches)) {
         // Get the page using match 1 (pagename)
         $page = get_page_by_path($matches[1]);
         // Abort if no page is found
         if (is_null($page)) {
             return;
         }
         // Get the post type, and validate that it exists
         if (($post_type = Registry::is_index_page($page->ID)) && post_type_exists($post_type)) {
             // Modify the request into a post type archive instead
             $qv['post_type'] = $post_type;
             list(, , $qv['year'], $qv['monthnum'], $qv['day'], $qv['paged']) = array_pad($matches, 6, null);
             // Make sure these are unset
             unset($qv['pagename']);
             unset($qv['page']);
             unset($qv['name']);
         }
     }
 }
开发者ID:dougwollison,项目名称:index-pages,代码行数:39,代码来源:class-indexpages-frontend.php


示例19: clear_menu_from_old_woo_pages

function clear_menu_from_old_woo_pages()
{
    $locations = get_nav_menu_locations();
    $logout = get_page_by_path('my-account/logout');
    $parent = get_page_by_path('my-account');
    $permalink = get_option('permalink_structure');
    $pages_deleted = array(get_option('woocommerce_pay_page_id'), get_option('woocommerce_thanks_page_id'), get_option('woocommerce_view_order_page_id'), get_option('woocommerce_view_order_page_id'), get_option('woocommerce_change_password_page_id'), get_option('woocommerce_edit_address_page_id'), get_option('woocommerce_lost_password_page_id'));
    foreach ((array) $locations as $name => $menu_ID) {
        $items = wp_get_nav_menu_items($menu_ID);
        foreach ((array) $items as $item) {
            if (!is_null($logout) && !is_null($parent) && $item->object_id == $logout->ID) {
                update_post_meta($item->ID, '_menu_item_object', 'custom');
                update_post_meta($item->ID, '_menu_item_type', 'custom');
                if ($permalink == '') {
                    $new_url = get_permalink($parent->ID) . '&customer-logout';
                } else {
                    wp_update_post(array('ID' => $logout->ID, 'post_name' => 'customer-logout'));
                    $new_url = get_permalink($logout->ID);
                }
                update_post_meta($item->ID, '_menu_item_url', $new_url);
                wp_update_post(array('ID' => $item->ID, 'post_title' => $logout->post_title));
            }
            foreach ($pages_deleted as $page) {
                if ($page && $item->object_id == $page && $item->object == 'page') {
                    wp_delete_post($item->ID);
                }
            }
        }
    }
}
开发者ID:jayeshnair,项目名称:ctp,代码行数:30,代码来源:woocommerce.php


示例20: getCommunityBrandingImage

 public function getCommunityBrandingImage($slugOfChapter)
 {
     $UI = new UI();
     $chapter = get_page_by_path($slugOfChapter, OBJECT, 'chapters');
     $image = $UI->getPostFeaturedImageURL(get_post_thumbnail_id($chapter->ID), 'original');
     echo $image;
 }
开发者ID:UWAA,项目名称:uwaa-2014,代码行数:7,代码来源:GetCommunitySlug.php



注:本文中的get_page_by_path函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_page_by_title函数代码示例发布时间:2022-05-15
下一篇:
PHP get_page_advanced函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap