isBook() static public method

Check if the current blog_id is considered a "book"
static public isBook ( ) : boolean
return boolean
コード例 #1
0
 /**
  * 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'));
         }
     }
 }
コード例 #2
0
	/**
	 * Adds and Removes some admin buttons
	 * 
	 * @since 1.0.1
	 */
	function adminMenuAdjuster() {
		if ( \Pressbooks\Book::isBook() ) {
			add_menu_page( __( 'Import', $this->plugin_slug ), __( 'Import', $this->plugin_slug ), 'edit_posts', 'pb_import', '\PressBooks\Admin\Laf\display_import', '', 15 );
			add_options_page( __( 'PressBooks Textbook Settings', $this->plugin_slug ), __( 'PB Textbook', $this->plugin_slug ), 'manage_options', $this->plugin_slug . '-settings', array( $this, 'displayPluginAdminPage' ) );
			add_menu_page( __( 'PressBooks Textbook', $this->plugin_slug ), __( 'PB Textbook', $this->plugin_slug ), 'edit_posts', $this->plugin_slug , array( $this, 'displayPBTPage' ), '', 64 );
			// check if the functionality we need is available
			if ( class_exists('\PressBooks\Api_v1\Api') ){
				add_submenu_page( $this->plugin_slug, __('Search and Import', $this->plugin_slug), __('Search and Import', $this->plugin_slug), 'edit_posts', 'api_search_import',array( $this, 'displayApiSearchPage' ), '', 65 );
			}
			add_submenu_page( $this->plugin_slug, __('Download Textbooks', $this->plugin_slug), __('Download Textbooks', $this->plugin_slug), 'edit_posts', 'download_textbooks',array( $this, 'displayDownloadTextbooks' ), '', 66 );
			add_menu_page( 'Plugins', 'Plugins', 'manage_network_plugins', 'plugins.php', '', 'dashicons-admin-plugins', 67 );
			remove_menu_page( 'pb_sell' );
		}
	}
コード例 #3
0
ファイル: candela-utility.php プロジェクト: BCcampus/candela
function add_theme($themes)
{
    $merge_themes = array();
    if (\Pressbooks\Book::isBook()) {
        $registered_themes = search_theme_directories();
        foreach ($registered_themes as $key => $val) {
            if ($val['theme_root'] == __DIR__ . '/themes') {
                $merge_themes[$key] = 1;
            }
        }
        // add our theme
        $themes = array_merge($themes, $merge_themes);
    }
    return $themes;
}
 /**
  * Add the plugin's specific themes to the PressBooks theme filter.
  * Inspirated from Textbook's one.
  *
  * @since    0.1
  * @param    array $themes The currently allowed themes in PressBooks
  * @return   array The array from the input, with the plugin's themes
  */
 public function add_themes_to_filter($themes)
 {
     $pbt_themes = array();
     if (\Pressbooks\Book::isBook()) {
         $registered_themes = search_theme_directories();
         foreach ($registered_themes as $key => $val) {
             if ($val['theme_root'] == plugin_dir_path(dirname(__FILE__)) . 'themes') {
                 $pbt_themes[$key] = 1;
             }
         }
         // add our theme to the whitelist
         $themes = array_merge($themes, $pbt_themes);
         return $themes;
     } else {
         return $themes;
     }
 }
コード例 #5
0
function hide_menus()
{
    global $wpdb;
    $user = wp_get_current_user();
    $restricted = $wpdb->get_results('SELECT * FROM wp_sitemeta WHERE meta_key = "pressbooks_network_managers"');
    if ($restricted) {
        $restricted = maybe_unserialize($restricted[0]->meta_value);
    } else {
        $restricted = array();
    }
    if (in_array($user->ID, $restricted) && !\PressBooks\Book::isBook()) {
        remove_menu_page("themes.php");
        remove_menu_page("plugins.php");
        remove_menu_page("settings.php");
        remove_menu_page("update-core.php");
        remove_menu_page("admin.php?page=pb_stats");
    }
}
コード例 #6
0
 /**
  * Adds and Removes some admin buttons
  * 
  * @since 1.0.1
  */
 function adminMenuAdjuster()
 {
     if (\Pressbooks\Book::isBook()) {
         add_menu_page(__('Import', $this->plugin_slug), __('Import', $this->plugin_slug), 'edit_posts', 'pb_import', '\\Pressbooks\\Admin\\Laf\\display_import', 'dashicons-upload', 15);
         add_options_page(__('Pressbooks Textbook Settings', $this->plugin_slug), __('PB Textbook', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-settings', array($this, 'displayPluginAdminPage'));
         add_menu_page(__('Pressbooks Textbook', $this->plugin_slug), __('PB Textbook', $this->plugin_slug), 'edit_posts', $this->plugin_slug, array($this, 'displayPBTPage'), 'dashicons-tablet', 64);
         // check if the functionality we need is available
         if (class_exists('\\Pressbooks\\Modules\\Api_v1\\Api')) {
             add_submenu_page($this->plugin_slug, __('Search and Import', $this->plugin_slug), __('Search and Import', $this->plugin_slug), 'edit_posts', 'api_search_import', array($this, 'displayApiSearchPage'), '', 65);
         }
         add_submenu_page($this->plugin_slug, __('Download Textbooks', $this->plugin_slug), __('Download Textbooks', $this->plugin_slug), 'edit_posts', 'download_textbooks', array($this, 'displayDownloadTextbooks'), '', 66);
         if (version_compare(PB_PLUGIN_VERSION, '2.7') >= 0) {
             remove_menu_page('pb_publish');
         } else {
             remove_menu_page('pb_sell');
         }
     }
 }
コード例 #7
0
 /**
  * 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 = get_post($pid);
     $order = $post->menu_order;
     $type = $post->post_type;
     $parent = $post->post_parent;
     $query = "UPDATE {$wpdb->posts} SET menu_order = menu_order - 1 WHERE menu_order > {$order} AND post_type = '{$type}' ";
     if ('chapter' == $type) {
         $query .= " AND post_parent = {$parent} ";
     }
     $success = $wpdb->query($query);
     clean_post_cache($post);
     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("SELECT ID\n\t\t\t\t\t\t\t\t\t\t FROM {$wpdb->posts}\n\t\t\t\t\t\t\t\t\t\tWHERE post_type = 'part'\n\t\t\t\t\t\t\t\t\t\t  AND post_status = 'publish'\n\t\t\t\t\t\t\t\t\t\t  AND NOT ID = {$pid}\n\t\t\t\t\t\t\t\t\t ORDER BY menu_order\n\t\t\t\t\t\t\t\t\t\tLIMIT 1 ");
         if ($new_parent_id) {
             $existing_numposts = $wpdb->get_var("SELECT COUNT(1) AS numposts FROM {$wpdb->posts} WHERE post_type = 'chapter' AND post_parent = {$new_parent_id} ");
             $query = "UPDATE {$wpdb->posts} SET post_parent = {$new_parent_id}, menu_order = menu_order + {$existing_numposts} WHERE post_parent = {$pid} AND post_type = 'chapter' ";
             $success = $wpdb->query($query);
         } else {
             $query = "UPDATE {$wpdb->posts} SET post_status = 'trash' WHERE post_parent = {$pid} AND post_type = 'chapter' ";
             $success = $wpdb->query($query);
         }
         wp_cache_flush();
     }
     static::deleteBookObjectCache();
     return $success ? true : false;
 }
コード例 #8
0
<?php

/**
 * Change core WordPress strings using $overrides array.
 *
 * @author  PressBooks <*****@*****.**>
 * @license GPLv2 (or any later version)
 * @see     pressbooks/includes/pb-l10n.php
 */
$overrides = array('My Sites' => 'Mina Böcker', 'Create a New Site' => 'Skapa en ny bok');
if (\PressBooks\Book::isBook()) {
    $overrides['Settings'] = 'Inställningar';
    $overrides['Visit Site'] = 'Besök Bok';
    $overrides['Edit Site'] = 'Visa Bok';
    $overrides['Du har använt din utrymmeskvot. Vänligen ta bort filer innan du lägger upp.'] = 'Tyvärr, du har använt alla dina lagringskvoten. Vill du ha mer utrymme? Uppgradera din bok.';
}
return $overrides;
コード例 #9
0
ファイル: pb-customcss.php プロジェクト: cumi/pressbooks
/**
 * Add Edit CSS menu.
 */
function add_menu()
{
    if (Book::isBook() && CustomCss::isCustomCss()) {
        add_theme_page(__('Edit CSS', 'pressbooks'), __('Edit CSS', 'pressbooks'), 'edit_theme_options', 'pb_custom_css', __NAMESPACE__ . '\\display_custom_css');
    }
}
コード例 #10
0
	/**
	 * Pressbooks filters allowed themes, this adds our themes to the list
	 * 
	 * @since 1.0.7
	 * @param array $themes
	 * @return array
	 */
	function filterChildThemes( $themes ) {
		$pbt_themes = array();

		if ( \Pressbooks\Book::isBook() ) {
			$registered_themes = search_theme_directories();

			foreach ( $registered_themes as $key => $val ) {
				if ( $val['theme_root'] == PBT_PLUGIN_DIR . 'themes-book' ) {
					$pbt_themes[$key] = 1;
				}
			}
			// add our theme
			$themes = array_merge( $themes, $pbt_themes );

			return $themes;
		} else {
			return $themes;
		}
	}