当前位置: 首页>>代码示例>>PHP>>正文


PHP Book::isBook方法代码示例

本文整理汇总了PHP中Book::isBook方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::isBook方法的具体用法?PHP Book::isBook怎么用?PHP Book::isBook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Book的用法示例。


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

示例1: registerThemeDirectories

 /**
  * Register theme directories, set a filter that hides themes under certain conditions
  */
 function registerThemeDirectories()
 {
     // No trailing slash, otherwise we get a double slash bug
     // @see \PressBooks\Metadata::fixDoubleSlashBug
     register_theme_directory(PB_PLUGIN_DIR . 'themes-root');
     register_theme_directory(PB_PLUGIN_DIR . 'themes-book');
     if (is_admin()) {
         if (Book::isBook()) {
             add_filter('allowed_themes', array($this, 'allowedBookThemes'));
         } else {
             add_filter('allowed_themes', array($this, 'allowedRootThemes'));
         }
     }
 }
开发者ID:cumi,项目名称:pressbooks,代码行数:17,代码来源:class-pb-pressbooks.php

示例2: registerThemeDirectories

 /**
  * Register theme directories, set a filter that hides themes under certain conditions
  */
 function registerThemeDirectories()
 {
     // No trailing slash, otherwise we get a double slash bug
     // @see \Pressbooks\Metadata::fixDoubleSlashBug
     register_theme_directory(PB_PLUGIN_DIR . 'themes-root');
     register_theme_directory(PB_PLUGIN_DIR . 'themes-book');
     do_action('pressbooks_register_theme_directory');
     // Check for local themes-root directory
     if (realpath(WP_CONTENT_DIR . '/themes-root')) {
         register_theme_directory(WP_CONTENT_DIR . '/themes-root');
     }
     if (is_admin()) {
         if (Book::isBook()) {
             add_filter('allowed_themes', array($this, 'allowedBookThemes'));
         } elseif (!is_network_admin()) {
             add_filter('allowed_themes', array($this, 'allowedRootThemes'));
         }
     }
 }
开发者ID:pressbooks,项目名称:pressbooks,代码行数:22,代码来源:class-pb-pressbooks.php

示例3: deletePost

 /**
  * Put a Part/Chapter/Front Matter/Back Matter in the trash
  *
  * @param int $pid
  *
  * @return bool
  */
 static function deletePost($pid)
 {
     if (false == Book::isBook() || wp_is_post_revision($pid) || 'auto-draft' == get_post_status($pid)) {
         return false;
     }
     /** @var $wpdb \wpdb */
     global $wpdb;
     // remove chapter/part/front matter
     // decrement order of everything with a higher order, and if chapter, only within that part
     $post_to_delete = get_post($pid);
     $order = $post_to_delete->menu_order;
     $type = $post_to_delete->post_type;
     $parent = $post_to_delete->post_parent;
     $query = "UPDATE {$wpdb->posts} SET menu_order = menu_order - 1 WHERE menu_order > {$order} AND post_type = '{$type}' ";
     if ('chapter' == $type) {
         $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET menu_order = menu_order - 1 WHERE menu_order > %d AND post_type = %s AND post_parent = %d ", $order, $type, $parent));
     } else {
         $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET menu_order = menu_order - 1 WHERE menu_order > %d AND post_type = %s ", $order, $type));
     }
     clean_post_cache($post_to_delete);
     if ('part' == $type) {
         // We're setting two things here - the new post_parent (to the first part)
         // And the new menu order for the chapters that were in the part being deleted.
         $new_parent_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'part' AND post_status = 'publish' AND NOT ID = %d ORDER BY menu_order LIMIT 1 ", $pid));
         if ($new_parent_id) {
             $existing_numposts = $wpdb->get_var($wpdb->prepare("SELECT COUNT(1) AS numposts FROM {$wpdb->posts} WHERE post_type = 'chapter' AND post_parent = %d ", $new_parent_id));
             $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = %d, menu_order = menu_order + %d WHERE post_parent = %d AND post_type = 'chapter' ", $new_parent_id, $existing_numposts, $pid));
         } else {
             $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_status = 'trash' WHERE post_parent = %d AND post_type = 'chapter' ", $pid));
         }
         wp_cache_flush();
     }
     static::deleteBookObjectCache();
     return $success ? true : false;
 }
开发者ID:pressbooks,项目名称:pressbooks,代码行数:42,代码来源:class-pb-book.php


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