* @author Christos Amyrotos @MashRoofa */ class Pressbooks_Metadata_General_Functions { function __construct() { } /** * A function that returns the active parent from the parent filter * @since 0.13 */ public static function get_active_parent(){ if(get_option('parent_filter_settings') == false){ $enabledParent = 'organization_properties'; }else{ $enabledParent = get_option('parent_filter_settings'); $enabledParent = $enabledParent['radio1']; } $parentNamespaces = structure::$allParents; foreach($parentNamespaces as $parent){ if($parent::type_name[1] == $enabledParent){ return $parent; } } } /** * Function used to remove null values from an array * @since 0.10 */ public static function remove_null($array) { $cleanArray = array(); foreach($array as $item){ if($item != NULL){ $cleanArray[]=$item; } } return $cleanArray; } /** * Function used to extract the name of the type from its settings * @since 0.10 */ static public function get_type_id($type) { foreach($type::$type_setting as $typeId => $details) { return $typeId; } } /** * A function that returns the correct metadata for the schemaTypes classes * If pressbooks is installed we return the metadata for the Book Info information * If pressbooks is not installed we return the Site Meta metadata * @since 0.9 */ public static function get_metadata(){ if(!site_cpt::pressbooks_identify()){ return site_cpt::get_site_meta_metadata(); }else{ return \Pressbooks\Book::getBookInformation(); } } /** * A function to retrieve the metatags we need for the Root level * of the website. In Pressbooks this is the catalog of the books. * * @since 0.8 */ public function get_root_level_metatags(){ $html = "\n" ."
\n" ." \n" ." \n" ." \n" ." \n" ."
\n"; return $html; } /** * A function to retrieve the data we need from the custom fields of PressBooks * for Google Scholar use. * * @since 0.7 */ public function get_googleScholar_metatags(){ // array of the items that we need from the General Book Information metabox $book_info_data = array( 'citation_journal_title' => 'pb_title', 'citation_author' => 'pb_author', 'citation_language' => 'pb_language', 'citation_keywords' => 'pb_keywords_tags', 'citation_isbn' => 'pb_ebook_isbn', 'citation_publisher' => 'pb_publisher', 'citation_publication_date' => 'pb_publication_date' ); $html = "\n"; //For the fields of General Book Information Metabox $metadata = \Pressbooks\Book::getBookInformation(); foreach ($book_info_data as $name => $content){ if ( isset( $metadata[$content] ) ) { // the date must be in a specific format (Y/m/d) if ( 'pb_publication_date' == $content ) { $metadata[$content] = date( 'Y/m/d', (int) $metadata[ $content ] ); } $html .= "\n"; } } return $html; } }