idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
60,000 | public static function create ( $ class , $ isConstructed , $ tagNumber ) { if ( ! is_numeric ( $ class ) || $ class < self :: CLASS_UNIVERSAL || $ class > self :: CLASS_PRIVATE ) { throw new Exception ( sprintf ( 'Invalid class %d given' , $ class ) ) ; } if ( ! is_bool ( $ isConstructed ) ) { throw new Exception ( "\... | Creates an identifier . Short form identifiers are returned as integers for BC long form identifiers will be returned as a string of octets . |
60,001 | public static function getName ( $ identifier ) { $ identifierOctet = self :: makeNumeric ( $ identifier ) ; $ typeName = static :: getShortName ( $ identifier ) ; if ( ( $ identifierOctet & self :: LONG_FORM ) < self :: LONG_FORM ) { $ typeName = "ASN.1 {$typeName}" ; } return $ typeName ; } | Return the name of the mapped ASN . 1 type with a preceding ASN . 1 . |
60,002 | public static function getShortName ( $ identifier ) { $ identifierOctet = self :: makeNumeric ( $ identifier ) ; switch ( $ identifierOctet ) { case self :: EOC : return 'End-of-contents octet' ; case self :: BOOLEAN : return 'Boolean' ; case self :: INTEGER : return 'Integer' ; case self :: BITSTRING : return 'Bit St... | Return the short version of the type name . |
60,003 | public static function getClassDescription ( $ identifier ) { $ identifierOctet = self :: makeNumeric ( $ identifier ) ; if ( self :: isConstructed ( $ identifierOctet ) ) { $ classDescription = 'Constructed ' ; } else { $ classDescription = 'Primitive ' ; } $ classBits = $ identifierOctet >> 6 ; switch ( $ classBits )... | Returns a textual description of the information encoded in a given identifier octet . |
60,004 | public function setColumnHeaders ( array $ columnHeaders ) { $ this -> columnHeaders = array_count_values ( $ columnHeaders ) ; $ this -> headersCount = count ( $ columnHeaders ) ; } | Set column headers |
60,005 | protected function readHeaderRow ( $ rowNumber ) { $ this -> file -> seek ( $ rowNumber ) ; $ headers = $ this -> file -> current ( ) ; $ diff = array_diff_assoc ( $ headers , array_unique ( $ headers ) ) ; if ( count ( $ diff ) > 0 ) { switch ( $ this -> duplicateHeadersFlag ) { case self :: DUPLICATE_HEADERS_INCREMEN... | Read header row from CSV file |
60,006 | protected function incrementHeaders ( array $ headers ) { $ incrementedHeaders = [ ] ; foreach ( array_count_values ( $ headers ) as $ header => $ count ) { if ( $ count > 1 ) { $ incrementedHeaders [ ] = $ header ; for ( $ i = 1 ; $ i < $ count ; $ i ++ ) { $ incrementedHeaders [ ] = $ header . $ i ; } } else { $ incr... | Add an increment to duplicate headers |
60,007 | protected function mergeDuplicates ( array $ line ) { $ values = [ ] ; $ i = 0 ; foreach ( $ this -> columnHeaders as $ count ) { if ( 1 === $ count ) { $ values [ ] = $ line [ $ i ] ; } else { $ values [ ] = array_slice ( $ line , $ i , $ count ) ; } $ i += $ count ; } return $ values ; } | Merges values for duplicate headers into an array |
60,008 | public function setSql ( $ sql , array $ params = [ ] ) { $ this -> sql = ( string ) $ sql ; $ this -> setSqlParameters ( $ params ) ; } | Set Query string with Parameters |
60,009 | public function setSqlParameters ( array $ params ) { $ this -> params = $ params ; $ this -> stmt = null ; $ this -> rowCount = null ; } | Set SQL parameters |
60,010 | private function prepare ( $ sql , array $ params ) { $ statement = $ this -> connection -> prepare ( $ sql ) ; foreach ( $ params as $ key => $ value ) { $ statement -> bindValue ( $ key , $ value ) ; } return $ statement ; } | Prepare given statement |
60,011 | public function addOption ( $ option , $ optionValue ) { if ( ! in_array ( $ option , $ this -> possibleOptions ) ) { return ; } $ this -> constraints [ $ option ] = $ optionValue ; } | Add additional options for the constraints |
60,012 | public function convert ( $ input ) { if ( ! $ input ) { return ; } if ( ! ( $ input instanceof \ DateTime ) ) { throw new UnexpectedValueException ( 'Input must be DateTime object.' ) ; } return $ input -> format ( $ this -> outputFormat ) ; } | Convert string to date time object using specified format |
60,013 | protected function getNewInstance ( ) { $ className = $ this -> entityMetadata -> getName ( ) ; if ( class_exists ( $ className ) === false ) { throw new \ Exception ( 'Unable to create new instance of ' . $ className ) ; } return new $ className ; } | Return a new instance of the entity |
60,014 | protected function setValue ( $ entity , $ value , $ setter ) { if ( method_exists ( $ entity , $ setter ) ) { $ entity -> $ setter ( $ value ) ; } } | Call a setter of the entity |
60,015 | protected function findOrCreateItem ( array $ item ) { $ entity = null ; if ( false === $ this -> truncate ) { if ( ! empty ( $ this -> lookupFields ) ) { $ lookupConditions = array ( ) ; foreach ( $ this -> lookupFields as $ fieldName ) { $ lookupConditions [ $ fieldName ] = $ item [ $ fieldName ] ; } $ entity = $ thi... | Finds existing entity or create a new instance |
60,016 | protected function loadData ( ) { if ( null === $ this -> data ) { $ this -> statement -> execute ( ) ; $ this -> data = $ this -> statement -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; } } | Load data if it hasn t been loaded yet |
60,017 | public function addStep ( Step $ step , $ priority = null ) { $ priority = null === $ priority && $ step instanceof PriorityStep ? $ step -> getPriority ( ) : $ priority ; $ priority = null === $ priority ? 0 : $ priority ; $ this -> steps -> insert ( $ step , $ priority ) ; return $ this ; } | Add a step to the current workflow |
60,018 | public function commit ( ConnectionInterface $ connection ) { $ this -> transactionLevel -- ; if ( ! $ this -> isPrepared ( $ connection ) || $ this -> transactionLevel > 0 ) { return ; } $ this -> dispatchPendingEvents ( $ connection ) ; } | Flush all pending events . |
60,019 | protected function prepareTransaction ( $ connection ) { $ connectionId = $ connection -> getName ( ) ; $ this -> transactionLevel = $ this -> transactionLevel > 0 ? $ this -> transactionLevel + 1 : 1 ; $ this -> pendingEvents [ $ connectionId ] [ $ this -> transactionLevel ] [ ] = [ ] ; } | Prepare to store events for the current transaction . |
60,020 | protected function addPendingEvent ( $ connection , $ event , $ payload ) { $ connectionId = $ connection -> getName ( ) ; $ transactionLevel = $ this -> transactionLevel ; $ eventData = [ 'event' => $ event , 'payload' => is_object ( $ payload ) ? clone $ payload : $ payload , ] ; $ transactionLevelEvents = & $ this -... | Add a transactional event waiting for transaction to commit . |
60,021 | protected function dispatchPendingEvents ( ConnectionInterface $ connection ) { $ connectionId = $ connection -> getName ( ) ; $ consumingEvents = $ this -> pendingEvents [ $ connectionId ] ; unset ( $ this -> pendingEvents [ $ connectionId ] ) ; foreach ( $ consumingEvents as $ transactionsEvents ) { foreach ( $ trans... | Flush all pending events for the given connection . |
60,022 | public function rollback ( ConnectionInterface $ connection ) { $ connectionId = $ connection -> getName ( ) ; if ( $ this -> transactionLevel > 1 ) { array_pop ( $ this -> pendingEvents [ $ connectionId ] [ $ this -> transactionLevel ] ) ; } else { unset ( $ this -> pendingEvents [ $ connectionId ] ) ; } $ this -> tra... | Clear enqueued events . |
60,023 | private function isTransactionalEvent ( ConnectionInterface $ connection , $ event ) { if ( $ this -> isPrepared ( $ connection ) && $ this -> transactionLevel > 0 ) { return $ this -> shouldHandle ( $ event ) ; } return false ; } | Check whether an event is a transactional event or not . |
60,024 | private function shouldHandle ( $ event ) { if ( $ event instanceof TransactionalEvent ) { return true ; } $ event = is_string ( $ event ) ? $ event : get_class ( $ event ) ; foreach ( $ this -> excluded as $ excluded ) { if ( $ this -> matches ( $ excluded , $ event ) ) { return false ; } } foreach ( $ this -> transac... | Check whether an event should be handled by this layer or not . |
60,025 | private function matches ( $ pattern , $ event ) { return ( Str :: contains ( $ pattern , '*' ) && Str :: is ( $ pattern , $ event ) ) || Str :: startsWith ( $ event , $ pattern ) ; } | Check whether an event name matches a pattern or not . |
60,026 | public function adminBar ( ) { global $ wp_admin_bar ; if ( ! $ wp_admin_bar instanceof \ WP_Admin_Bar ) { return ; } $ nodes = $ wp_admin_bar -> get_nodes ( ) ; if ( ! is_iterable ( $ nodes ) ) { return ; } $ relationships = [ ] ; foreach ( $ nodes as $ id => $ node ) { $ parent = ! empty ( $ node -> parent ) ? $ node... | Create links from Admin Bar |
60,027 | private function printMenuTree ( ) { global $ menu , $ submenu ; if ( ! is_iterable ( $ menu ) ) { return ; } echo '<ul class="ul-disc">' ; foreach ( $ menu as $ arr1 ) { if ( empty ( $ arr1 [ 0 ] ) ) { continue ; } $ menu_hook = get_plugin_page_hook ( $ arr1 [ 2 ] , null ) ; if ( $ menu_hook ) { $ href = 'admin.php?pa... | Print Menu & Submenu Tree |
60,028 | public function apiInit ( ) { try { if ( ! is_plugin_active ( 'h5p/h5p.php' ) ) { \ H5P_Plugin :: get_instance ( ) -> rest_api_init ( ) ; } if ( get_option ( 'blog_public' ) ) { add_filter ( 'h5p_rest_api_all_permission' , '__return_true' ) ; } } catch ( \ Throwable $ e ) { return false ; } return true ; } | Defines REST API callbacks |
60,029 | public function fetch ( $ url ) { try { $ new_h5p_id = \ H5P_Plugin :: get_instance ( ) -> fetch_h5p ( $ url ) ; } catch ( \ Throwable $ e ) { $ new_h5p_id = 0 ; } return $ new_h5p_id ; } | Download and add H5P content from given url . |
60,030 | protected function getChapterParent ( ) { $ q = new \ WP_Query ( ) ; $ args = [ 'post_type' => 'part' , 'post_status' => [ 'draft' , 'web-only' , 'private' , 'publish' ] , 'posts_per_page' => 1 , 'orderby' => 'menu_order' , 'order' => 'ASC' , 'no_found_rows' => true , 'cache_results' => false , 'update_post_meta_cache'... | Get a valid Part id to act as post_parent to a Chapter |
60,031 | protected function flaggedForImport ( $ id ) { $ chapters = getset ( '_POST' , 'chapters' ) ; if ( ! is_array ( $ chapters ) ) { return false ; } if ( ! isset ( $ chapters [ $ id ] ) ) { return false ; } if ( ! isset ( $ chapters [ $ id ] [ 'import' ] ) ) { return false ; } return ( 1 === ( int ) $ chapters [ $ id ] [ ... | Check against what the user selected for import in our form |
60,032 | protected function determinePostType ( $ id ) { $ chapters = getset ( '_POST' , 'chapters' ) ; $ supported_types = apply_filters ( 'pb_import_custom_post_types' , [ 'front-matter' , 'chapter' , 'part' , 'back-matter' , 'metadata' , 'glossary' ] ) ; $ default = 'chapter' ; if ( ! is_array ( $ chapters ) ) { return $ def... | Check against what the user selected for post_type in our form |
60,033 | static protected function isUrlSmallerThanUploadMaxSize ( $ url , $ max ) { $ response = wp_safe_remote_head ( $ url , [ 'redirection' => 2 , ] ) ; $ size = ( int ) wp_remote_retrieve_header ( $ response , 'Content-Length' ) ; if ( empty ( $ size ) ) { return true ; } return ( $ max >= $ size ) ; } | Check that a URL is smaller than MAX UPLOAD without downloading the file |
60,034 | static public function hooks ( Attachments $ obj ) { add_shortcode ( self :: SHORTCODE , [ $ obj , 'shortcodeHandler' ] ) ; add_filter ( 'no_texturize_shortcodes' , function ( $ excluded_shortcodes ) { $ excluded_shortcodes [ ] = Attachments :: SHORTCODE ; return $ excluded_shortcodes ; } ) ; add_filter ( 'media_embedd... | Hooks our bits into the machine |
60,035 | function getBookMedia ( $ reset = false ) { static $ book_media = null ; if ( $ reset || $ book_media === null ) { $ book_media = [ ] ; $ args = [ 'post_type' => 'attachment' , 'posts_per_page' => - 1 , 'post_status' => 'inherit' , 'no_found_rows' => true , ] ; $ attached_media = get_posts ( $ args ) ; foreach ( $ atta... | Returns the array of attachments set in the instance variable . |
60,036 | function getAttributions ( $ content ) { $ media_in_page = get_media_embedded_in_content ( $ content ) ; if ( empty ( $ media_in_page ) ) { return $ content ; } $ book_media = $ this -> getBookMedia ( ) ; if ( ! empty ( $ book_media ) ) { $ media_ids = Media \ extract_id_from_media ( $ media_in_page ) ; $ unique_ids = ... | Produces a list of media attributions if they are found in the current page and part of the media library appends said list to the end of the content |
60,037 | public function getAttributionsMeta ( $ ids ) { $ all_attributions = [ ] ; if ( $ ids ) { foreach ( $ ids as $ id ) { $ all_attributions [ $ id ] [ 'title' ] = get_the_title ( $ id ) ; $ all_attributions [ $ id ] [ 'title_url' ] = get_post_meta ( $ id , 'pb_media_attribution_title_url' , true ) ; $ all_attributions [ $... | Returns the gamut of attribution metadata that can be associated with an attachment |
60,038 | function attributionsContent ( $ attributions ) { $ media_attributions = '' ; $ html = '' ; $ licensing = new Licensing ( ) ; $ supported = $ licensing -> getSupportedTypes ( ) ; if ( $ attributions ) { foreach ( $ attributions as $ attribution ) { $ attribution = array_filter ( $ attribution , 'strlen' ) ; if ( count ... | Produces an html blob of attribution statements for the array of attachment ids it s given . |
60,039 | static public function commandLineDefaults ( ) { if ( ! defined ( 'PB_CONVERT_COMMAND' ) ) { define ( 'PB_CONVERT_COMMAND' , '/usr/bin/convert' ) ; } if ( ! defined ( 'PB_GS_COMMAND' ) ) { define ( 'PB_GS_COMMAND' , '/usr/bin/gs' ) ; } if ( ! defined ( 'PB_PDFINFO_COMMAND' ) ) { define ( 'PB_PDFINFO_COMMAND' , '/usr/bi... | Set defaults for command line utilities |
60,040 | function getExportStylePath ( $ type ) { $ fullpath = false ; if ( CustomCss :: isCustomCss ( ) ) { $ fullpath = CustomCss :: getCustomCssFolder ( ) . "$type.css" ; if ( ! is_file ( $ fullpath ) ) { $ fullpath = false ; } } if ( ! $ fullpath ) { $ fullpath = Container :: get ( 'Styles' ) -> getPathToScss ( $ type ) ; i... | Return the fullpath to an export module s style file . |
60,041 | function truncateExportStylesheets ( $ type , $ max = 1 ) { if ( in_array ( $ type , [ 'prince' ] , true ) ) { $ stylesheets = scandir_by_date ( Container :: get ( 'Sass' ) -> pathToUserGeneratedCss ( ) ) ; $ max = absint ( $ max ) ; $ i = 1 ; foreach ( $ stylesheets as $ stylesheet ) { if ( preg_match ( '/(' . $ type ... | Remove all but the most recent compiled stylesheet . |
60,042 | function getExportScriptPath ( $ type ) { $ fullpath = false ; if ( CustomCss :: isCustomCss ( ) ) { $ fullpath = CustomCss :: getCustomCssFolder ( ) . "/$type.js" ; if ( ! is_file ( $ fullpath ) ) { $ fullpath = false ; } } if ( ! $ fullpath ) { $ dir = Container :: get ( 'Styles' ) -> getDir ( ) ; if ( Container :: g... | Return the fullpath to an export module s Javascript file . |
60,043 | function getExportScriptUrl ( $ type ) { $ url = false ; $ dir = Container :: get ( 'Styles' ) -> getDir ( ) ; if ( Container :: get ( 'Styles' ) -> isCurrentThemeCompatible ( 2 ) && realpath ( "$dir/assets/scripts/$type/script.js" ) ) { $ url = apply_filters ( 'pb_stylesheet_directory_uri' , get_stylesheet_directory_u... | Return the public URL to an export module s Javascript file . |
60,044 | function verifyNonce ( $ timestamp , $ md5 ) { $ within_range = time ( ) - $ timestamp ; if ( $ within_range > ( MINUTE_IN_SECONDS * 5 ) ) { return false ; } if ( md5 ( NONCE_KEY . $ timestamp ) !== $ md5 ) { return false ; } return true ; } | Verify that a NONCE was created within a range of 5 minutes and is valid . |
60,045 | protected function preProcessPostName ( $ id ) { if ( in_array ( $ id , $ this -> reservedIds , true ) ) { $ id = uniqid ( "$id-" ) ; } return \ Pressbooks \ Sanitize \ sanitize_xml_id ( $ id ) ; } | Check a post_name against a list of reserved IDs sanitize for use as an XML ID . |
60,046 | protected function createTmpDir ( ) { $ temp_file = tempnam ( sys_get_temp_dir ( ) , '' ) ; @ unlink ( $ temp_file ) ; mkdir ( $ temp_file ) ; if ( ! is_dir ( $ temp_file ) ) { return '' ; } return untrailingslashit ( $ temp_file ) ; } | Create a temporary directory no trailing slash! |
60,047 | protected function transformXML ( $ content , $ path_to_xsl ) { libxml_use_internal_errors ( true ) ; $ content = iconv ( 'UTF-8' , 'UTF-8//IGNORE' , $ content ) ; $ xsl = new \ DOMDocument ( ) ; $ xsl -> load ( $ path_to_xsl ) ; $ proc = new \ XSLTProcessor ( ) ; $ proc -> importStyleSheet ( $ xsl ) ; $ old_value = li... | Convert an XML string via XSLT file . |
60,048 | protected function doCopyrightLicense ( $ metadata , $ title = '' , $ id = 0 , $ section_author = '' ) { if ( ! empty ( $ section_author ) ) { _deprecated_argument ( __METHOD__ , '4.1.0' ) ; } try { $ licensing = new \ Pressbooks \ Licensing ( ) ; return $ licensing -> doLicense ( $ metadata , $ id , $ title ) ; } catc... | Will create an html blob of copyright returns empty string if something goes wrong |
60,049 | protected function doTocLicense ( $ post_id ) { $ option = get_option ( 'pressbooks_theme_options_global' ) ; if ( ! empty ( $ option [ 'copyright_license' ] ) ) { if ( 1 === absint ( $ option [ 'copyright_license' ] ) ) { $ section_license = get_post_meta ( $ post_id , 'pb_section_license' , true ) ; if ( ! empty ( $ ... | Returns a string of text to be used in TOC returns empty string if user doesn t want it displayed |
60,050 | protected function loadTemplate ( $ path , array $ vars = [ ] ) { try { return \ Pressbooks \ Utility \ template ( $ path , $ vars ) ; } catch ( \ Exception $ e ) { if ( WP_DEBUG ) { return "File not found: {$path}" ; } else { return '' ; } } } | Simple template system . |
60,051 | static function getExportFolder ( ) { $ path = \ Pressbooks \ Utility \ get_media_prefix ( ) . 'exports/' ; if ( ! file_exists ( $ path ) ) { wp_mkdir_p ( $ path ) ; } $ path_to_htaccess = $ path . '.htaccess' ; if ( ! file_exists ( $ path_to_htaccess ) ) { \ Pressbooks \ Utility \ put_contents ( $ path_to_htaccess , "... | Get the fullpath to the Exports folder . Create if not there . Create . htaccess protection if missing . |
60,052 | static function preExport ( ) { do_action ( 'pb_pre_export' ) ; $ last_export = get_option ( 'pressbooks_last_export' ) ; $ within_range = time ( ) - $ last_export ; if ( $ within_range > ( HOUR_IN_SECONDS ) ) { \ Pressbooks \ Book :: deleteBookObjectCache ( ) ; update_option ( 'pressbooks_last_export' , time ( ) ) ; }... | Pre - Export |
60,053 | static function isFormSubmission ( ) { if ( empty ( $ _REQUEST [ 'page' ] ) ) { return false ; } if ( 'pb_export' !== $ _REQUEST [ 'page' ] ) { return false ; } if ( $ _SERVER [ 'REQUEST_METHOD' ] === 'POST' ) { return true ; } if ( count ( $ _GET ) > 1 ) { return true ; } return false ; } | Check if a user submitted something to admin . php?page = pb_export |
60,054 | public function gitHubUpdater ( ) { static $ updater = null ; if ( $ updater === null ) { $ updater = \ Puc_v4_Factory :: buildUpdateChecker ( 'https://github.com/pressbooks/pressbooks/' , untrailingslashit ( PB_PLUGIN_DIR ) . '/pressbooks.php' , 'pressbooks' , 24 ) ; $ updater -> setBranch ( 'master' ) ; $ updater -> ... | GitHub Plugin Update Checker Hooked into action plugins_loaded |
60,055 | public function getPluginsWithHeader ( $ header ) { $ plugins = get_plugins ( ) ; $ matches = [ ] ; foreach ( $ plugins as $ file => $ plugin ) { if ( $ plugin [ 'Name' ] === 'Pressbooks' ) { continue ; } if ( ! empty ( $ plugin [ $ header ] ) ) { $ matches [ $ file ] = $ plugin ; } } return $ matches ; } | Get plugins that have a specific header |
60,056 | public function getPluginsWithPressbooksInDescription ( ) { $ plugins = get_plugins ( ) ; $ matches = [ ] ; foreach ( $ plugins as $ file => $ plugin ) { if ( $ plugin [ 'Name' ] === 'Pressbooks' ) { continue ; } if ( stristr ( $ plugin [ 'Name' ] , 'pressbooks' ) || stristr ( $ plugin [ 'Description' ] , 'pressbooks' ... | Get plugins with Pressbooks in the description |
60,057 | public function addTooltipScripts ( ) { if ( ! is_admin ( ) ) { $ assets = new Assets ( 'pressbooks' , 'plugin' ) ; wp_enqueue_script ( 'glossary-tooltip' , $ assets -> getPath ( 'scripts/glossary-tooltip.js' ) , false , null , true ) ; wp_enqueue_style ( 'glossary-tooltip' , $ assets -> getPath ( 'styles/glossary-tool... | Add JavaScript for the tooltip |
60,058 | public function getGlossaryTerms ( $ reset = false ) { static $ glossary_terms = null ; if ( $ reset || $ glossary_terms === null ) { $ glossary_terms = [ ] ; $ args = [ 'post_type' => 'glossary' , 'posts_per_page' => - 1 , 'post_status' => [ 'private' , 'publish' ] , ] ; $ posts = get_posts ( $ args ) ; foreach ( $ po... | Gets the instance variable of glossary terms returns as an array of key = post_title id = post ID content = post_content . Sets an instance variable |
60,059 | public function getGlossaryTermsListbox ( $ reset = false ) { $ values [ ] = [ 'text' => '-- ' . __ ( 'Select' , 'pressbooks' ) . ' --' , 'value' => '' , ] ; $ terms = $ this -> getGlossaryTerms ( $ reset ) ; foreach ( $ terms as $ title => $ term ) { $ values [ ] = [ 'text' => \ Pressbooks \ Sanitize \ decode ( $ titl... | For tiny mce Get both published and private terms |
60,060 | public function glossaryTooltip ( $ glossary_term_id , $ content ) { global $ id ; $ glossary_term = get_post ( $ glossary_term_id ) ; if ( ! $ glossary_term ) { return $ content . 'no post' ; } if ( $ glossary_term -> post_status === 'trash' ) { return $ content ; } $ html = '<button class="glossary-term" aria-describ... | Returns the tooltip markup and content |
60,061 | public function webShortcodeHandler ( $ atts , $ content ) { global $ id ; $ a = shortcode_atts ( [ 'id' => '' , 'type' => '' , ] , $ atts ) ; if ( ! empty ( $ content ) ) { if ( $ a [ 'id' ] ) { if ( ! isset ( $ this -> glossaryTerms [ $ id ] ) ) { $ this -> glossaryTerms [ $ id ] = [ ] ; } if ( ! isset ( $ this -> gl... | Webbook shortcode Gets the tooltip if the param contains the post id or a list of terms if it s just the short - code |
60,062 | function tooltipContent ( $ content ) { global $ id ; if ( ! empty ( $ this -> glossaryTerms ) && isset ( $ this -> glossaryTerms [ $ id ] ) ) { $ glossary_terms = $ this -> glossaryTerms [ $ id ] ; } else { return $ content ; } $ content .= '<div class="glossary">' ; foreach ( $ glossary_terms as $ glossary_term_id =>... | Post - process glossary shortcode creating content for tooltips |
60,063 | public function backMatterAutoDisplay ( $ content ) { $ post = get_post ( ) ; if ( ! $ post ) { global $ id ; $ post = get_post ( $ id ) ; } if ( ! $ post ) { return $ content ; } if ( $ post -> post_type !== 'back-matter' ) { return $ content ; } $ taxonomy = \ Pressbooks \ Taxonomy :: init ( ) ; if ( $ taxonomy -> ge... | Automatically display shortcode list in Glossary back matter if content is empty |
60,064 | function mediaType ( $ file ) { $ mime = static :: mimeType ( $ file ) ; $ mime = explode ( ';' , $ mime ) ; $ mime = trim ( $ mime [ 0 ] ) ; return $ mime ; } | Override mimeType get rid of ; charset = binary |
60,065 | protected function html5ToXhtml ( $ html ) { $ config = [ 'valid_xhtml' => 1 , 'unique_ids' => 0 , ] ; $ html = \ Pressbooks \ HtmLawed :: filter ( $ html , $ config ) ; return $ html ; } | Clean up content processed by HTML5 Parser change it back into XHTML |
60,066 | protected function zipEpub ( $ filename ) { $ zip = new \ PclZip ( $ filename ) ; $ list = $ zip -> create ( $ this -> tmpDir . '/mimetype' , PCLZIP_OPT_NO_COMPRESSION , PCLZIP_OPT_REMOVE_ALL_PATH ) ; if ( 0 === absint ( $ list ) ) { return false ; } $ files = [ ] ; foreach ( new \ RecursiveIteratorIterator ( new \ Rec... | Zip the contents of an EPUB following the conventions outlined in Open Publication Structure 2 . 0 . 1 |
60,067 | protected function createContainer ( ) { \ Pressbooks \ Utility \ put_contents ( $ this -> tmpDir . '/mimetype' , utf8_decode ( 'application/epub+zip' ) ) ; mkdir ( $ this -> tmpDir . '/META-INF' ) ; mkdir ( $ this -> tmpDir . '/OEBPS' ) ; mkdir ( $ this -> tmpDir . '/OEBPS/assets' ) ; \ Pressbooks \ Utility \ put_cont... | Create Open Publication Structure 2 . 0 . 1 container . |
60,068 | protected function scrapeKneadAndSaveCss ( $ path_to_original_stylesheet , $ path_to_copy_of_stylesheet ) { $ styles = Container :: get ( 'Styles' ) ; $ scss = \ Pressbooks \ Utility \ get_contents ( $ path_to_copy_of_stylesheet ) ; if ( $ this -> extraCss ) { $ scss .= "\n" . $ this -> loadTemplate ( $ this -> extraCs... | Parse CSS copy assets rewrite copy . |
60,069 | protected function positionOfToc ( ) { $ search = array_keys ( $ this -> manifest ) ; if ( false === $ this -> frontMatterLastPos ) { $ array_pos = array_search ( 'copyright' , $ search , true ) ; if ( false === $ array_pos ) { $ array_pos = - 1 ; } } else { $ array_pos = - 1 ; $ preg = '/^front-matter-' . sprintf ( '%... | Determine position of TOC based on Chicago Manual Of Style . |
60,070 | protected function kneadHtml ( $ html , $ type , $ pos = 0 ) { $ html5 = new HtmlParser ( ) ; $ dom = $ html5 -> loadHTML ( $ html , [ 'disable_html_ns' => true ] ) ; $ dom = $ this -> scrapeAndKneadImages ( $ dom ) ; $ dom = $ this -> scrapeAndKneadMedia ( $ dom ) ; $ dom = $ this -> kneadHref ( $ dom , $ type , $ pos... | Pummel the HTML into EPUB compatible dough . |
60,071 | protected function fixOrder ( $ order ) { $ fixed = [ ] ; $ fm = [ ] ; foreach ( $ order as $ post_id => $ val ) { if ( $ val [ 'post_type' ] === 'front-matter' ) { $ type = $ this -> taxonomy -> getFrontMatterType ( $ post_id ) ; if ( ! in_array ( $ type , [ 'before-title' , 'title-page' , 'dedication' , 'epigraph' ] ... | Reorder the book structure to conform to Chicago Style so that the book begins with Before Title Title Page Dedication Epigraph . |
60,072 | protected function buildManifestAssetsHtml ( ) { $ html = '' ; $ path_to_assets = $ this -> tmpDir . '/OEBPS/assets' ; $ assets = scandir ( $ path_to_assets ) ; $ used_ids = [ ] ; foreach ( $ assets as $ asset ) { if ( '.' === $ asset || '..' === $ asset ) { continue ; } $ mimetype = $ this -> mediaType ( "$path_to_ass... | Find all the image files insert them into the OPF file |
60,073 | public static function getCoversFolder ( ) { $ path = \ Pressbooks \ Utility \ get_media_prefix ( ) . 'covers/' ; if ( ! file_exists ( $ path ) ) { mkdir ( $ path , 0775 , true ) ; } $ path_to_htaccess = $ path . '.htaccess' ; if ( ! file_exists ( $ path_to_htaccess ) ) { \ Pressbooks \ Utility \ put_contents ( $ path_... | Get the fullpath to the Covers folder . Create if not there . Create . htaccess protection if missing . |
60,074 | protected function getScssVars ( ) { $ sass = '' ; foreach ( $ this -> requiredSassVars as $ var ) { $ method = $ this -> varToGetter ( $ var ) ; if ( ! method_exists ( $ this -> input , $ method ) ) { throw new \ LogicException ( "Input::{$method}() not found." ) ; } if ( empty ( $ this -> input -> { $ method } ( ) ) ... | Generate SCSS vars based on Input object |
60,075 | public static function formDeleteAll ( ) { if ( ! empty ( $ _POST [ 'delete_all_covers' ] ) && check_admin_referer ( 'pb-delete-all-covers' ) ) { \ Pressbooks \ Utility \ truncate_exports ( 0 , static :: getCoversFolder ( ) ) ; delete_transient ( 'dirsize_cache' ) ; } \ Pressbooks \ Redirect \ location ( admin_url ( 'a... | Delete all covers |
60,076 | public function timestampedFileName ( $ extension , $ fullpath = true ) { $ book_title = ( get_bloginfo ( 'name' ) ) ? get_bloginfo ( 'name' ) : __ ( 'book' , 'pressbooks' ) ; $ book_title_slug = sanitize_file_name ( $ book_title ) ; $ book_title_slug = str_replace ( [ '+' ] , '' , $ book_title_slug ) ; $ book_title_sl... | Create a timestamped filename . |
60,077 | static function renderColorField ( $ args ) { $ defaults = [ 'id' => null , 'name' => null , 'option' => null , 'value' => '' , 'default' => '#000' , 'description' => null , 'disabled' => false , ] ; $ args = wp_parse_args ( $ args , $ defaults ) ; printf ( '<input id="%1$s" class="color-picker" name="%2$s[%3$s]" type=... | Render a WordPress color picker . |
60,078 | static function renderCheckbox ( $ args ) { $ defaults = [ 'id' => null , 'name' => null , 'option' => null , 'value' => '' , 'label' => null , 'disabled' => false , 'description' => null , ] ; $ args = wp_parse_args ( $ args , $ defaults ) ; printf ( '<input id="%s" name="%s[%s]" type="checkbox" value="1" %s%s/><label... | Render a checkbox . |
60,079 | static function renderRadioButtons ( $ args ) { $ defaults = [ 'id' => null , 'name' => null , 'option' => null , 'value' => '' , 'choices' => [ ] , 'custom' => false , 'disabled' => false , ] ; $ args = wp_parse_args ( $ args , $ defaults ) ; $ is_custom = false ; if ( ! array_key_exists ( $ args [ 'value' ] , $ args ... | Render radio buttons . |
60,080 | static function renderSelect ( $ args ) { $ defaults = [ 'id' => null , 'name' => null , 'option' => null , 'value' => '' , 'choices' => [ ] , 'multiple' => false , 'disabled' => false , 'description' => null , ] ; $ args = wp_parse_args ( $ args , $ defaults ) ; $ options = '' ; foreach ( $ args [ 'choices' ] as $ key... | Render a select element . |
60,081 | static function renderCustomSelect ( $ args ) { $ defaults = [ 'id' => null , 'name' => null , 'value' => '' , 'choices' => [ ] , 'multiple' => false , 'disabled' => false , ] ; $ args = wp_parse_args ( $ args , $ defaults ) ; $ is_custom = false ; if ( ! array_key_exists ( $ args [ 'value' ] , $ args [ 'choices' ] ) )... | Render a custom select element . |
60,082 | protected function removeAttributionLink ( $ content ) { $ html5 = new HtmlParser ( ) ; $ dom = $ html5 -> loadHTML ( $ content ) ; $ urls = $ dom -> getElementsByTagName ( 'a' ) ; foreach ( $ urls as $ url ) { if ( $ url -> getAttribute ( 'rel' ) === 'cc:attributionURL' ) { $ url -> parentNode -> replaceChild ( $ dom ... | Removes the CC attribution link . |
60,083 | protected function fixImages ( $ content ) { static $ already_done = [ ] ; $ changed = false ; $ html5 = new HtmlParser ( ) ; $ dom = $ html5 -> loadHTML ( $ content ) ; $ images = $ dom -> getElementsByTagName ( 'img' ) ; foreach ( $ images as $ image ) { $ old_src = $ image -> getAttribute ( 'src' ) ; if ( isset ( $ ... | Replace every image with the bigger original image |
60,084 | protected function atLeastOneExport ( array $ chapters ) { foreach ( $ chapters as $ key => $ val ) { if ( is_array ( $ val ) ) { $ found = $ this -> atLeastOneExport ( $ val ) ; if ( $ found ) { return true ; } else { continue ; } } elseif ( 'export' === ( string ) $ key && $ val ) { return true ; } } return false ; } | Does array of chapters have at least one export? Recursive . |
60,085 | static function hasDependencies ( ) { if ( false !== \ Pressbooks \ Utility \ check_epubcheck_install ( ) && false !== \ Pressbooks \ Utility \ check_kindlegen_install ( ) ) { return true ; } return false ; } | Dependency check . |
60,086 | function getSupportedLanguages ( ) { return [ 'grc' => __ ( 'Ancient Greek' , 'pressbooks' ) , 'ar' => __ ( 'Arabic' , 'pressbooks' ) , 'bn' => __ ( 'Bengali' , 'pressbooks' ) , 'he' => __ ( 'Biblical Hebrew' , 'pressbooks' ) , 'cans' => __ ( 'Canadian Indigenous Syllabics' , 'pressbooks' ) , 'hi' => __ ( 'Devanagari (... | Get Pressbooks - supported languages . |
60,087 | function getThemeFontStacks ( $ type ) { $ return_value = '' ; $ fullpath = $ this -> sass -> pathToUserGeneratedSass ( ) . "/_font-stack-{$type}.scss" ; if ( is_file ( $ fullpath ) ) { $ return_value = \ Pressbooks \ Utility \ get_contents ( $ fullpath ) ; } return $ return_value ; } | Get the current theme s font stacks . |
60,088 | function _getRequiredLanguages ( ) { $ languages = get_option ( 'pressbooks_global_typography' , [ ] ) ; $ book_lang = $ this -> _getBookLanguage ( ) ; if ( ! empty ( $ book_lang ) ) { $ languages [ ] = $ book_lang ; } if ( is_array ( $ this -> getThemeSupportedLanguages ( ) ) ) { $ languages = array_unique ( array_mer... | Get required languages for this book excluding those supported by the theme . |
60,089 | function getThemeSupportedLanguages ( ) { $ return_value = false ; $ fullpath = get_stylesheet_directory ( ) . '/theme-information.php' ; if ( is_file ( $ fullpath ) ) { require ( $ fullpath ) ; if ( ! empty ( $ supported_languages ) ) { $ return_value = $ supported_languages ; } } else { $ return_value = get_theme_sup... | Get the current theme s supported languages . |
60,090 | function getFonts ( $ languages = null ) { if ( ! $ languages ) { $ languages = $ this -> _getRequiredLanguages ( ) ; } $ basepath = WP_CONTENT_DIR . '/uploads/assets/fonts/' ; if ( ! is_dir ( $ basepath ) ) { mkdir ( $ basepath , 0755 , true ) ; } $ fontpacks = [ 'bn' => [ 'baseurl' => 'https://github.com/googlei18n/n... | Check for absent font files and download if necessary . |
60,091 | public function searchHead ( ) { $ assets = new Assets ( 'pressbooks' , 'plugin' ) ; wp_enqueue_style ( 'search-and-replace' , $ assets -> getPath ( 'styles/search-and-replace.css' ) ) ; wp_register_script ( 'search-and-replace' , $ assets -> getPath ( 'scripts/search-and-replace.js' ) ) ; wp_localize_script ( 'search-... | Load styles and scripts |
60,092 | function get_columns ( ) { $ profile = ( new Catalog ( ) ) -> getProfile ( ) ; $ columns = [ 'cb' => '<input type="checkbox" />' , 'status' => __ ( 'Catalog Status' , 'pressbooks' ) , 'privacy' => __ ( 'Privacy Status' , 'pressbooks' ) , 'cover' => __ ( 'Cover' , 'pressbooks' ) , 'title' => __ ( 'Title' , 'pressbooks' ... | This method dictates the table s columns and titles . |
60,093 | function print_column_headers ( $ with_id = true ) { if ( isset ( $ _POST [ 'pb_catalog_search' ] ) ) { if ( ! wp_verify_nonce ( esc_attr ( $ _POST [ 'pb_catalog_search' ] ) , 'pb_catalog_search' ) ) { die ( 'Security check.' ) ; } } if ( empty ( $ _GET [ 's' ] ) && ! empty ( $ _POST [ 's' ] ) ) { $ _SERVER [ 'REQUEST_... | Form is POST not GET . Override parent method to compensate . |
60,094 | static function addSearchParamsToUrl ( $ url ) { if ( ! empty ( $ _REQUEST [ 's' ] ) ) { $ url = esc_url ( add_query_arg ( 's' , $ _REQUEST [ 's' ] , $ url ) ) ; } if ( ! empty ( $ _REQUEST [ 'orderby' ] ) ) { $ url = esc_url ( add_query_arg ( 'orderby' , $ _REQUEST [ 'orderby' ] , $ url ) ) ; } if ( ! empty ( $ _REQUE... | Rebuild a URL with known search parameters |
60,095 | static function viewCatalogUrl ( ) { if ( isset ( $ _REQUEST [ 'user_id' ] ) ) { if ( false === current_user_can ( 'edit_user' , ( int ) $ _REQUEST [ 'user_id' ] ) ) { wp_die ( __ ( 'You do not have permission to do that.' ) ) ; } $ u = get_userdata ( ( int ) $ _REQUEST [ 'user_id' ] ) ; if ( false === $ u ) { wp_die (... | Generate catalog URL . Dies on problem . |
60,096 | function feed_links ( $ args = array ( ) ) { if ( ! current_theme_supports ( 'automatic-feed-links' ) ) return ; $ defaults = array ( 'separator' => _x ( '»' , 'feed link' ) , 'feedtitle' => __ ( '%1$s %2$s Feed' ) , ) ; $ args = wp_parse_args ( $ args , $ defaults ) ; echo '<link rel="alternate" type="' . feed_c... | Not required after WP 4 . 4 |
60,097 | function renderChapterNumbersField ( $ args ) { unset ( $ args [ 'label_for' ] , $ args [ 'class' ] ) ; $ this -> renderCheckbox ( [ 'id' => 'chapter_numbers' , 'name' => 'pressbooks_theme_options_' . $ this -> getSlug ( ) , 'option' => 'chapter_numbers' , 'value' => ( isset ( $ this -> options [ 'chapter_numbers' ] ) ... | Render the chapter_numbers checkbox . |
60,098 | function renderTwoLevelTOCField ( $ args ) { unset ( $ args [ 'label_for' ] , $ args [ 'class' ] ) ; $ this -> renderCheckbox ( [ 'id' => 'parse_subsections' , 'name' => 'pressbooks_theme_options_' . $ this -> getSlug ( ) , 'option' => 'parse_subsections' , 'value' => ( isset ( $ this -> options [ 'parse_subsections' ]... | Render the parse_subsections checkbox . |
60,099 | function renderAttachmentAttributionsField ( $ args ) { unset ( $ args [ 'label_for' ] , $ args [ 'class' ] ) ; $ this -> renderCheckbox ( [ 'id' => 'attachment_attributions' , 'name' => 'pressbooks_theme_options_' . $ this -> getSlug ( ) , 'option' => 'attachment_attributions' , 'value' => ( isset ( $ this -> options ... | Render the attachment_attributions checkbox . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.