From 9ddb9760e16e0aac107819163e09a82c1a5f9327 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 13 Oct 2021 09:50:03 -0400 Subject: [PATCH 01/65] Reorganizes the template tags functions --- functions.php | 15 +- inc/template-tags.php | 446 ------------------ inc/template-tags/display_comments.php | 11 + inc/template-tags/display_copyright_text.php | 14 + inc/template-tags/display_mobile_menu.php | 43 ++ .../display_numeric_pagination.php | 40 ++ .../display_social_network_links.php | 54 +++ inc/template-tags/display_svg.php | 48 ++ inc/template-tags/entry_footer.php | 42 ++ inc/template-tags/get_svg.php | 103 ++++ inc/template-tags/get_the_excerpt.php | 25 + inc/template-tags/get_the_title.php | 23 + inc/template-tags/posted_on.php | 35 ++ 13 files changed, 451 insertions(+), 448 deletions(-) delete mode 100644 inc/template-tags.php create mode 100644 inc/template-tags/display_comments.php create mode 100644 inc/template-tags/display_copyright_text.php create mode 100644 inc/template-tags/display_mobile_menu.php create mode 100644 inc/template-tags/display_numeric_pagination.php create mode 100644 inc/template-tags/display_social_network_links.php create mode 100644 inc/template-tags/display_svg.php create mode 100644 inc/template-tags/entry_footer.php create mode 100644 inc/template-tags/get_svg.php create mode 100644 inc/template-tags/get_the_excerpt.php create mode 100644 inc/template-tags/get_the_title.php create mode 100644 inc/template-tags/posted_on.php diff --git a/functions.php b/functions.php index 676995593..b1491053a 100644 --- a/functions.php +++ b/functions.php @@ -22,10 +22,21 @@ function _s_get_theme_include_files() { 'inc/security.php', // WordPress hardening. 'inc/scaffolding.php', // Scaffolding. 'inc/scripts.php', // Load styles and scripts. - 'inc/template-tags.php', // Custom template tags for this theme. + 'inc/template-tags/', // Custom template tags for this theme. + 'inc/functions/', // Custom template tags for this theme. + 'inc/post-types/', // Custom template tags for this theme. ]; } foreach ( _s_get_theme_include_files() as $include ) { - require trailingslashit( get_template_directory() ) . $include; + $include = trailingslashit( get_template_directory() ) . $include; + + // Allows inclusion of individual files or all .php files in a directory. + if ( is_dir( $include ) ) { + foreach ( glob( $include . '*.php' ) as $file ) { + require $file; + } + } else { + require $include; + } } diff --git a/inc/template-tags.php b/inc/template-tags.php deleted file mode 100644 index cf6fd0c5b..000000000 --- a/inc/template-tags.php +++ /dev/null @@ -1,446 +0,0 @@ -%2$s'; - if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { - $time_string = ''; - } - - $time_string = sprintf( - $time_string, - esc_attr( get_the_date( DATE_W3C ) ), - esc_html( get_the_date() ), - esc_attr( get_the_modified_date( DATE_W3C ) ), - esc_html( get_the_modified_date() ) - ); - - $posted_on = sprintf( - /* translators: the date the post was published */ - esc_html_x( 'Posted on %s', 'post date', '_s' ), - '' . $time_string . '' - ); - - $byline = sprintf( - /* translators: the post author */ - esc_html_x( 'by %s', 'post author', '_s' ), - '' . esc_html( get_the_author() ) . '' - ); - - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. - echo '' . $posted_on . ' ' . $byline . ''; -} - -/** - * Prints HTML with meta information for the categories, tags and comments. - * - * @author WebDevStudios - */ -function _s_entry_footer() { - // Hide category and tag text for pages. - if ( 'post' === get_post_type() ) { - /* translators: used between list items, there is a space after the comma */ - $categories_list = get_the_category_list( esc_attr__( ', ', '_s' ) ); - if ( $categories_list && _s_categorized_blog() ) { - - /* translators: the post category */ - printf( '' . esc_attr__( 'Posted in %1$s', '_s' ) . '', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. - } - - /* translators: used between list items, there is a space after the comma */ - $tags_list = get_the_tag_list( '', esc_attr__( ', ', '_s' ) ); - if ( $tags_list ) { - - /* translators: the post tags */ - printf( '' . esc_attr__( 'Tagged %1$s', '_s' ) . '', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. - } - } - - if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { - echo ''; - comments_popup_link( esc_attr__( 'Leave a comment', '_s' ), esc_attr__( '1 Comment', '_s' ), esc_attr__( '% Comments', '_s' ) ); - echo ''; - } - - edit_post_link( - sprintf( - /* translators: %s: Name of current post */ - esc_html__( 'Edit %s', '_s' ), - wp_kses_post( get_the_title( '"', '"', false ) ) - ), - '', - '' - ); -} - -/** - * Display SVG Markup. - * - * @author WebDevStudios - * - * @param array $args The parameters needed to get the SVG. - */ -function _s_display_svg( $args = [] ) { - $kses_defaults = wp_kses_allowed_html( 'post' ); - - $svg_args = [ - 'svg' => [ - 'class' => true, - 'aria-hidden' => true, - 'aria-labelledby' => true, - 'role' => true, - 'xmlns' => true, - 'width' => true, - 'height' => true, - 'viewbox' => true, // <= Must be lower case! - 'color' => true, - 'stroke-width' => true, - ], - 'g' => [ 'color' => true ], - 'title' => [ - 'title' => true, - 'id' => true, - ], - 'path' => [ - 'd' => true, - 'color' => true, - ], - 'use' => [ - 'xlink:href' => true, - ], - ]; - - $allowed_tags = array_merge( - $kses_defaults, - $svg_args - ); - - echo wp_kses( - _s_get_svg( $args ), - $allowed_tags - ); -} - -/** - * Return SVG markup. - * - * @author WebDevStudios - * - * @param array $args The parameters needed to display the SVG. - * - * @return string Error string or SVG markup. - */ -function _s_get_svg( $args = [] ) { - // Make sure $args are an array. - if ( empty( $args ) ) { - return esc_attr__( 'Please define default parameters in the form of an array.', '_s' ); - } - - // Define an icon. - if ( false === array_key_exists( 'icon', $args ) ) { - return esc_attr__( 'Please define an SVG icon filename.', '_s' ); - } - - // Set defaults. - $defaults = [ - 'color' => '', - 'icon' => '', - 'title' => '', - 'desc' => '', - 'stroke-width' => '', - 'height' => '', - 'width' => '', - ]; - - // Parse args. - $args = wp_parse_args( $args, $defaults ); - - // Figure out which title to use. - $block_title = ( $args['title'] ) ? $args['title'] : $args['icon']; - - // Generate random IDs for the title and description. - $random_number = wp_rand( 0, 99999 ); - $block_title_id = 'title-' . sanitize_title( $block_title ) . '-' . $random_number; - $desc_id = 'desc-' . sanitize_title( $block_title ) . '-' . $random_number; - - // Set ARIA. - $aria_hidden = ' aria-hidden="true"'; - $aria_labelledby = ''; - - if ( $args['title'] && $args['desc'] ) { - $aria_labelledby = ' aria-labelledby="' . $block_title_id . ' ' . $desc_id . '"'; - $aria_hidden = ''; - } - - // Set SVG parameters. - $color = ( $args['color'] ) ? ' color="' . $args['color'] . '"' : ''; - $stroke_width = ( $args['stroke-width'] ) ? ' stroke-width="' . $args['stroke-width'] . '"' : ''; - $height = ( $args['height'] ) ? ' height="' . $args['height'] . '"' : ''; - $width = ( $args['width'] ) ? ' width="' . $args['width'] . '"' : ''; - - // Start a buffer... - ob_start(); - ?> - - - class="icon " - - role="img"> - - - - - - - - - - - - - - - - - - - 12, - 'more' => '...', - ]; - - // Parse args. - $args = wp_parse_args( $args, $defaults ); - - // Trim the title. - return wp_kses_post( wp_trim_words( get_the_title( get_the_ID() ), $args['length'], $args['more'] ) ); -} - -/** - * Limit the excerpt length. - * - * @author WebDevStudios - * - * @param array $args Parameters include length and more. - * - * @return string The excerpt. - */ -function _s_get_the_excerpt( $args = [] ) { - - // Set defaults. - $defaults = [ - 'length' => 20, - 'more' => '...', - 'post' => '', - ]; - - // Parse args. - $args = wp_parse_args( $args, $defaults ); - - // Trim the excerpt. - return wp_trim_words( get_the_excerpt( $args['post'] ), absint( $args['length'] ), esc_html( $args['more'] ) ); -} - -/** - * Echo the copyright text saved in the Customizer. - * - * @author WebDevStudios - */ -function _s_display_copyright_text() { - // Grab our customizer settings. - $copyright_text = get_theme_mod( '_s_copyright_text' ); - - if ( $copyright_text ) { - echo _s_get_the_content( do_shortcode( $copyright_text ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. - } -} - -/** - * Display the social links saved in the customizer. - * - * @author WebDevStudios - */ -function _s_display_social_network_links() { - // Create an array of our social links for ease of setup. - // Change the order of the networks in this array to change the output order. - $social_networks = [ - 'facebook', - 'instagram', - 'linkedin', - 'twitter', - ]; - - ?> - - max_num_pages ) ? $query->max_num_pages : 1; - - // Set defaults. - $defaults = [ - 'prev_text' => '«', - 'next_text' => '»', - 'mid_size' => 4, - 'total' => $total_pages, - ]; - - // Parse args. - $args = wp_parse_args( $args, $defaults ); - - if ( null === paginate_links( $args ) ) { - return; - } - ?> - - - - -
- - +
+ + max_num_pages ) ? $query->max_num_pages : 1; + + // Set defaults. + $defaults = [ + 'prev_text' => '«', + 'next_text' => '»', + 'mid_size' => 4, + 'total' => $total_pages, + ]; + + // Parse args. + $args = wp_parse_args( $args, $defaults ); + + if ( null === paginate_links( $args ) ) { + return; + } + ?> + + + + + + [ + 'class' => true, + 'aria-hidden' => true, + 'aria-labelledby' => true, + 'role' => true, + 'xmlns' => true, + 'width' => true, + 'height' => true, + 'viewbox' => true, // <= Must be lower case! + 'color' => true, + 'stroke-width' => true, + ], + 'g' => [ 'color' => true ], + 'title' => [ + 'title' => true, + 'id' => true, + ], + 'path' => [ + 'd' => true, + 'color' => true, + ], + 'use' => [ + 'xlink:href' => true, + ], + ]; + + $allowed_tags = array_merge( + $kses_defaults, + $svg_args + ); + + echo wp_kses( + _s_get_svg( $args ), + $allowed_tags + ); +} diff --git a/inc/template-tags/entry_footer.php b/inc/template-tags/entry_footer.php new file mode 100644 index 000000000..55cb9a6ce --- /dev/null +++ b/inc/template-tags/entry_footer.php @@ -0,0 +1,42 @@ +' . esc_attr__( 'Posted in %1$s', '_s' ) . '', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. + } + + /* translators: used between list items, there is a space after the comma */ + $tags_list = get_the_tag_list( '', esc_attr__( ', ', '_s' ) ); + if ( $tags_list ) { + + /* translators: the post tags */ + printf( '' . esc_attr__( 'Tagged %1$s', '_s' ) . '', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. + } + } + + if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { + echo ''; + comments_popup_link( esc_attr__( 'Leave a comment', '_s' ), esc_attr__( '1 Comment', '_s' ), esc_attr__( '% Comments', '_s' ) ); + echo ''; + } + + edit_post_link( + sprintf( + /* translators: %s: Name of current post */ + esc_html__( 'Edit %s', '_s' ), + wp_kses_post( get_the_title( '"', '"', false ) ) + ), + '', + '' + ); +} diff --git a/inc/template-tags/get_svg.php b/inc/template-tags/get_svg.php new file mode 100644 index 000000000..7e45b86e9 --- /dev/null +++ b/inc/template-tags/get_svg.php @@ -0,0 +1,103 @@ + '', + 'icon' => '', + 'title' => '', + 'desc' => '', + 'stroke-width' => '', + 'height' => '', + 'width' => '', + ]; + + // Parse args. + $args = wp_parse_args( $args, $defaults ); + + // Figure out which title to use. + $block_title = ( $args['title'] ) ? $args['title'] : $args['icon']; + + // Generate random IDs for the title and description. + $random_number = wp_rand( 0, 99999 ); + $block_title_id = 'title-' . sanitize_title( $block_title ) . '-' . $random_number; + $desc_id = 'desc-' . sanitize_title( $block_title ) . '-' . $random_number; + + // Set ARIA. + $aria_hidden = ' aria-hidden="true"'; + $aria_labelledby = ''; + + if ( $args['title'] && $args['desc'] ) { + $aria_labelledby = ' aria-labelledby="' . $block_title_id . ' ' . $desc_id . '"'; + $aria_hidden = ''; + } + + // Set SVG parameters. + $color = ( $args['color'] ) ? ' color="' . $args['color'] . '"' : ''; + $stroke_width = ( $args['stroke-width'] ) ? ' stroke-width="' . $args['stroke-width'] . '"' : ''; + $height = ( $args['height'] ) ? ' height="' . $args['height'] . '"' : ''; + $width = ( $args['width'] ) ? ' width="' . $args['width'] . '"' : ''; + + // Start a buffer... + ob_start(); + ?> + + + class="icon " + + role="img"> + + + + + + + + + + + + + + + + + + + 20, + 'more' => '...', + 'post' => '', + ]; + + // Parse args. + $args = wp_parse_args( $args, $defaults ); + + // Trim the excerpt. + return wp_trim_words( get_the_excerpt( $args['post'] ), absint( $args['length'] ), esc_html( $args['more'] ) ); +} diff --git a/inc/template-tags/get_the_title.php b/inc/template-tags/get_the_title.php new file mode 100644 index 000000000..bec7a3410 --- /dev/null +++ b/inc/template-tags/get_the_title.php @@ -0,0 +1,23 @@ + 12, + 'more' => '...', + ]; + + // Parse args. + $args = wp_parse_args( $args, $defaults ); + + // Trim the title. + return wp_kses_post( wp_trim_words( get_the_title( get_the_ID() ), $args['length'], $args['more'] ) ); +} diff --git a/inc/template-tags/posted_on.php b/inc/template-tags/posted_on.php new file mode 100644 index 000000000..41e2bfc38 --- /dev/null +++ b/inc/template-tags/posted_on.php @@ -0,0 +1,35 @@ +%2$s'; + if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { + $time_string = ''; + } + + $time_string = sprintf( + $time_string, + esc_attr( get_the_date( DATE_W3C ) ), + esc_html( get_the_date() ), + esc_attr( get_the_modified_date( DATE_W3C ) ), + esc_html( get_the_modified_date() ) + ); + + $posted_on = sprintf( + /* translators: the date the post was published */ + esc_html_x( 'Posted on %s', 'post date', '_s' ), + '' . $time_string . '' + ); + + $byline = sprintf( + /* translators: the post author */ + esc_html_x( 'by %s', 'post author', '_s' ), + '' . esc_html( get_the_author() ) . '' + ); + + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. + echo '' . $posted_on . ' ' . $byline . ''; +} From bfe5a43dc7fbfdab36b41f25b4c62be92b607836 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 13 Oct 2021 14:59:04 -0400 Subject: [PATCH 02/65] Breaks all of the functions in inc/ files out into individual files --- functions.php | 15 +- inc/extras.php | 123 ------ inc/{ => functions}/compat.php | 0 inc/functions/get_attachment_id_from_url.php | 39 ++ inc/functions/get_categorized_blog.php | 29 ++ inc/functions/get_custom_logo_url.php | 22 + .../get_the_excerpt.php | 0 .../get_the_title.php | 0 inc/{ => functions}/security.php | 0 inc/hooks.php | 396 ------------------ inc/hooks/add_og_tags.php | 143 +++++++ inc/hooks/body_classes.php | 68 +++ inc/hooks/category_transient_flusher.php | 21 + inc/hooks/content_more_link.php | 15 + inc/hooks/custom_mime_types.php | 20 + inc/hooks/disable_wpautop_for_gutenberg.php | 16 + .../display_customizer_footer_scripts.php | 25 ++ .../display_customizer_header_scripts.php | 25 ++ inc/hooks/excerpt_more.php | 17 + inc/hooks/get_the_content.php | 17 + inc/hooks/include_svg_icons.php | 21 + inc/hooks/remove_archive_title_prefix.php | 24 ++ inc/scaffolding.php | 258 ------------ .../display_global_scaffolding_section.php | 83 ++++ .../display_scaffolding_section.php | 92 ++++ inc/scaffolding/hook_theme_scaffolding.php | 21 + inc/scaffolding/scaffolding_allowed_html.php | 62 +++ inc/scripts.php | 71 ---- inc/setup/content_width.php | 17 + inc/setup/preload_assets.php | 16 + inc/setup/preload_scripts.php | 26 ++ inc/setup/scripts.php | 29 ++ inc/{ => setup}/setup.php | 56 +-- inc/setup/widgets_init.php | 35 ++ inc/shortcodes/copyright_year.php | 33 ++ inc/template-tags/README.md | 0 .../scaffolding.php | 0 .../sidebar-right.php | 0 38 files changed, 924 insertions(+), 911 deletions(-) delete mode 100644 inc/extras.php rename inc/{ => functions}/compat.php (100%) create mode 100644 inc/functions/get_attachment_id_from_url.php create mode 100644 inc/functions/get_categorized_blog.php create mode 100644 inc/functions/get_custom_logo_url.php rename inc/{template-tags => functions}/get_the_excerpt.php (100%) rename inc/{template-tags => functions}/get_the_title.php (100%) rename inc/{ => functions}/security.php (100%) delete mode 100644 inc/hooks.php create mode 100644 inc/hooks/add_og_tags.php create mode 100644 inc/hooks/body_classes.php create mode 100644 inc/hooks/category_transient_flusher.php create mode 100644 inc/hooks/content_more_link.php create mode 100644 inc/hooks/custom_mime_types.php create mode 100644 inc/hooks/disable_wpautop_for_gutenberg.php create mode 100644 inc/hooks/display_customizer_footer_scripts.php create mode 100644 inc/hooks/display_customizer_header_scripts.php create mode 100644 inc/hooks/excerpt_more.php create mode 100644 inc/hooks/get_the_content.php create mode 100644 inc/hooks/include_svg_icons.php create mode 100644 inc/hooks/remove_archive_title_prefix.php delete mode 100644 inc/scaffolding.php create mode 100644 inc/scaffolding/display_global_scaffolding_section.php create mode 100644 inc/scaffolding/display_scaffolding_section.php create mode 100644 inc/scaffolding/hook_theme_scaffolding.php create mode 100644 inc/scaffolding/scaffolding_allowed_html.php delete mode 100644 inc/scripts.php create mode 100644 inc/setup/content_width.php create mode 100644 inc/setup/preload_assets.php create mode 100644 inc/setup/preload_scripts.php create mode 100644 inc/setup/scripts.php rename inc/{ => setup}/setup.php (72%) create mode 100644 inc/setup/widgets_init.php create mode 100644 inc/shortcodes/copyright_year.php create mode 100644 inc/template-tags/README.md rename template-scaffolding.php => page-templates/scaffolding.php (100%) rename template-sidebar-right.php => page-templates/sidebar-right.php (100%) diff --git a/functions.php b/functions.php index b1491053a..5f4da0a62 100644 --- a/functions.php +++ b/functions.php @@ -14,17 +14,14 @@ */ function _s_get_theme_include_files() { return [ - 'inc/setup.php', // Theme set up. Should be included first. - 'inc/compat.php', // Backwards Compatibility. 'inc/customizer/customizer.php', // Customizer additions. - 'inc/extras.php', // Custom functions that act independently of the theme templates. - 'inc/hooks.php', // Load custom filters and hooks. - 'inc/security.php', // WordPress hardening. - 'inc/scaffolding.php', // Scaffolding. - 'inc/scripts.php', // Load styles and scripts. + 'inc/functions/', // Custom functions that act independently of the theme templates. + 'inc/hooks/', // Load custom filters and hooks. + 'inc/post-types/', // Load custom post types. + 'inc/scaffolding/', // Scaffolding. + 'inc/setup/', // Theme setup. + 'inc/shortcodes/', // Load shortcodes. 'inc/template-tags/', // Custom template tags for this theme. - 'inc/functions/', // Custom template tags for this theme. - 'inc/post-types/', // Custom template tags for this theme. ]; } diff --git a/inc/extras.php b/inc/extras.php deleted file mode 100644 index 121fa3732..000000000 --- a/inc/extras.php +++ /dev/null @@ -1,123 +0,0 @@ - 'count' ] ); - - $category_count = isset( $category_count_query[0] ) ? (int) $category_count_query[0] : 0; - - set_transient( '_s_categories', $category_count ); - } - - return $category_count > 1; -} - -/** - * Get an attachment ID from it's URL. - * - * @author WebDevStudios - * - * @param string $attachment_url The URL of the attachment. - * - * @return int The attachment ID. - */ -function _s_get_attachment_id_from_url( $attachment_url = '' ) { - global $wpdb; - - $attachment_id = false; - - // If there is no url, return. - if ( '' === $attachment_url ) { - return false; - } - - // Get the upload directory paths. - $upload_dir_paths = wp_upload_dir(); - - // Make sure the upload path base directory exists in the attachment URL, to verify that we're working with a media library image. - if ( false !== strpos( $attachment_url, $upload_dir_paths['baseurl'] ) ) { - - // If this is the URL of an auto-generated thumbnail, get the URL of the original image. - $attachment_url = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url ); - - // Remove the upload path base directory from the attachment URL. - $attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url ); - - // Do something with $result. - // phpcs:ignore phpcs:ignore WordPress.DB -- db call ok, cache ok, placeholder ok. - $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = %s AND wposts.post_type = 'attachment'", $attachment_url ) ); - } - - return $attachment_id; -} - -/** - * Shortcode to display copyright year. - * - * @author Haris Zulfiqar - * - * @param array $atts Optional attributes. - * $starting_year Optional. Define starting year to show starting year and current year e.g. 2015 - 2018. - * $separator Optional. Separator between starting year and current year. - * - * @return string Copyright year text. - */ -function _s_copyright_year( $atts ) { - // Setup defaults. - $args = shortcode_atts( - [ - 'starting_year' => '', - 'separator' => ' - ', - ], - $atts - ); - - $current_year = gmdate( 'Y' ); - - // Return current year if starting year is empty. - if ( ! $args['starting_year'] ) { - return $current_year; - } - - return esc_html( $args['starting_year'] . $args['separator'] . $current_year ); -} - -add_shortcode( '_s_copyright_year', '_s_copyright_year', 15 ); - -/** - * Retrieve the URL of the custom logo uploaded, if one exists. - * - * @author Corey Collins - */ -function _s_get_custom_logo_url() { - - $custom_logo_id = get_theme_mod( 'custom_logo' ); - - if ( ! $custom_logo_id ) { - return; - } - - $custom_logo_image = wp_get_attachment_image_src( $custom_logo_id, 'full' ); - - if ( ! isset( $custom_logo_image[0] ) ) { - return; - } - - return $custom_logo_image[0]; -} diff --git a/inc/compat.php b/inc/functions/compat.php similarity index 100% rename from inc/compat.php rename to inc/functions/compat.php diff --git a/inc/functions/get_attachment_id_from_url.php b/inc/functions/get_attachment_id_from_url.php new file mode 100644 index 000000000..8121c1e1a --- /dev/null +++ b/inc/functions/get_attachment_id_from_url.php @@ -0,0 +1,39 @@ +get_var( $wpdb->prepare( "SELECT wposts.ID FROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = %s AND wposts.post_type = 'attachment'", $attachment_url ) ); + } + + return $attachment_id; +} diff --git a/inc/functions/get_categorized_blog.php b/inc/functions/get_categorized_blog.php new file mode 100644 index 000000000..cd71cb0bd --- /dev/null +++ b/inc/functions/get_categorized_blog.php @@ -0,0 +1,29 @@ + 'count' ] ); + + $category_count = isset( $category_count_query[0] ) ? (int) $category_count_query[0] : 0; + + set_transient( '_s_categories', $category_count ); + } + + return $category_count > 1; +} diff --git a/inc/functions/get_custom_logo_url.php b/inc/functions/get_custom_logo_url.php new file mode 100644 index 000000000..e0ef2430c --- /dev/null +++ b/inc/functions/get_custom_logo_url.php @@ -0,0 +1,22 @@ + with the_content(); - * - * @author WebDevStudios - * - * @return string Read more link. - */ -function _s_content_more_link() { - return ' ' . esc_html__( 'Read More', '_s' ) . '...'; -} - -add_filter( 'the_content_more_link', '_s_content_more_link' ); - -/** - * Customize the [...] on the_excerpt(); - * - * @author WebDevStudios - * - * @param string $more The current $more string. - * - * @return string Read more link. - */ -function _s_excerpt_more( $more ) { - return sprintf( ' %2$s', get_permalink( get_the_ID() ), esc_html__( 'Read more...', '_s' ) ); -} - -add_filter( 'excerpt_more', '_s_excerpt_more' ); - -/** - * Filters WYSIWYG content with the_content filter. - * - * @author Jo Murgel - * - * @param string $content content dump from WYSIWYG. - * - * @return string|bool Content string if content exists, else empty. - */ -function _s_get_the_content( $content ) { - return ! empty( $content ) ? $content : false; -} - -add_filter( 'the_content', '_s_get_the_content', 20 ); - -/** - * Enable custom mime types. - * - * @author WebDevStudios - * - * @param array $mimes Current allowed mime types. - * - * @return array Mime types. - */ -function _s_custom_mime_types( $mimes ) { - $mimes['svg'] = 'image/svg+xml'; - $mimes['svgz'] = 'image/svg+xml'; - - return $mimes; -} - -add_filter( 'upload_mimes', '_s_custom_mime_types' ); - -/** - * Add SVG definitions to footer. - * - * @author WebDevStudios - */ -function _s_include_svg_icons() { - // Define SVG sprite file. - $svg_icons = get_template_directory() . '/build/images/icons/sprite.svg'; - - // If it exists, include it. - if ( file_exists( $svg_icons ) ) { - echo '
'; - require_once $svg_icons; - echo '
'; - } -} - -add_action( 'wp_footer', '_s_include_svg_icons', 9999 ); - -/** - * Display the customizer header scripts. - * - * @author Greg Rickaby - * - * @return string Header scripts. - */ -function _s_display_customizer_header_scripts() { - // Check for header scripts. - $scripts = get_theme_mod( '_s_header_scripts' ); - - // None? Bail... - if ( ! $scripts ) { - return false; - } - - // Otherwise, echo the scripts! - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. - echo _s_get_the_content( $scripts ); -} - -add_action( 'wp_head', '_s_display_customizer_header_scripts', 999 ); - -/** - * Display the customizer footer scripts. - * - * @author Greg Rickaby - * - * @return string Footer scripts. - */ -function _s_display_customizer_footer_scripts() { - // Check for footer scripts. - $scripts = get_theme_mod( '_s_footer_scripts' ); - - // None? Bail... - if ( ! $scripts ) { - return false; - } - - // Otherwise, echo the scripts! - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. - echo _s_get_the_content( $scripts ); -} - -add_action( 'wp_footer', '_s_display_customizer_footer_scripts', 999 ); - -/** - * Adds OG tags to the head for better social sharing. - * - * @author Corey Collins - * - * @return string An empty string if Yoast is not found, otherwise a block of meta tag HTML. - */ -function _s_add_og_tags() { - // Bail if Yoast is installed, since it will handle things. - if ( class_exists( 'WPSEO_Options' ) ) { - return ''; - } - - // Set a post global on single posts. This avoids grabbing content from the first post on an archive page. - if ( is_singular() ) { - global $post; - } - - // Get the post content. - $post_content = ! empty( $post ) ? $post->post_content : ''; - - // Strip all tags from the post content we just grabbed. - $default_content = ( $post_content ) ? wp_strip_all_tags( strip_shortcodes( $post_content ) ) : $post_content; - - // Set our default title. - $default_title = get_bloginfo( 'name' ); - - // Set our default URL. - $default_url = get_permalink(); - - // Set our base description. - $default_base_description = ( get_bloginfo( 'description' ) ) ? get_bloginfo( 'description' ) : esc_html__( 'Visit our website to learn more.', '_s' ); - - // Set the card type. - $default_type = 'article'; - - // Get our custom logo URL. We'll use this on archives and when no featured image is found. - $logo_id = get_theme_mod( 'custom_logo' ); - $logo_image = ( $logo_id ) ? wp_get_attachment_image_src( $logo_id, 'full' ) : ''; - $logo_url = ( $logo_id ) ? $logo_image[0] : ''; - - // Set our final defaults. - $card_title = $default_title; - $card_description = $default_base_description; - $card_long_description = $default_base_description; - $card_url = $default_url; - $card_image = $logo_url; - $card_type = $default_type; - - // Let's start overriding! - // All singles. - if ( is_singular() ) { - - if ( has_post_thumbnail() ) { - $card_image = get_the_post_thumbnail_url(); - } - } - - // Single posts/pages that aren't the front page. - if ( is_singular() && ! is_front_page() ) { - - $card_title = get_the_title() . ' - ' . $default_title; - $card_description = ( $default_content ) ? wp_trim_words( $default_content, 53, '...' ) : $default_base_description; - $card_long_description = ( $default_content ) ? wp_trim_words( $default_content, 140, '...' ) : $default_base_description; - } - - // Categories, Tags, and Custom Taxonomies. - if ( is_category() || is_tag() || is_tax() ) { - - $term_name = single_term_title( '', false ); - $card_title = $term_name . ' - ' . $default_title; - $specify = ( is_category() ) ? esc_html__( 'categorized in', '_s' ) : esc_html__( 'tagged with', '_s' ); - $queried_object = get_queried_object(); - $card_url = get_term_link( $queried_object ); - $card_type = 'website'; - - // Translators: get the term name. - $card_long_description = sprintf( esc_html__( 'Posts %1$s %2$s.', '_s' ), $specify, $term_name ); - $card_description = $card_long_description; - } - - // Search results. - if ( is_search() ) { - - $search_term = get_search_query(); - $card_title = $search_term . ' - ' . $default_title; - $card_url = get_search_link( $search_term ); - $card_type = 'website'; - - // Translators: get the search term. - $card_long_description = sprintf( esc_html__( 'Search results for %s.', '_s' ), $search_term ); - $card_description = $card_long_description; - } - - if ( is_home() ) { - - $posts_page = get_option( 'page_for_posts' ); - $card_title = get_the_title( $posts_page ) . ' - ' . $default_title; - $card_url = get_permalink( $posts_page ); - $card_type = 'website'; - } - - // Front page. - if ( is_front_page() ) { - - $front_page = get_option( 'page_on_front' ); - $card_title = ( $front_page ) ? get_the_title( $front_page ) . ' - ' . $default_title : $default_title; - $card_url = get_home_url(); - $card_type = 'website'; - } - - // Post type archives. - if ( is_post_type_archive() ) { - - $post_type_name = get_post_type(); - $card_title = $post_type_name . ' - ' . $default_title; - $card_url = get_post_type_archive_link( $post_type_name ); - $card_type = 'website'; - } - - // Media page. - if ( is_attachment() ) { - $attachment_id = get_the_ID(); - $card_image = ( wp_attachment_is_image( $attachment_id ) ) ? wp_get_attachment_image_url( $attachment_id, 'full' ) : $card_image; - } - - ?> - - - - - - - - - - post_content : ''; + + // Strip all tags from the post content we just grabbed. + $default_content = ( $post_content ) ? wp_strip_all_tags( strip_shortcodes( $post_content ) ) : $post_content; + + // Set our default title. + $default_title = get_bloginfo( 'name' ); + + // Set our default URL. + $default_url = get_permalink(); + + // Set our base description. + $default_base_description = ( get_bloginfo( 'description' ) ) ? get_bloginfo( 'description' ) : esc_html__( 'Visit our website to learn more.', '_s' ); + + // Set the card type. + $default_type = 'article'; + + // Get our custom logo URL. We'll use this on archives and when no featured image is found. + $logo_id = get_theme_mod( 'custom_logo' ); + $logo_image = ( $logo_id ) ? wp_get_attachment_image_src( $logo_id, 'full' ) : ''; + $logo_url = ( $logo_id ) ? $logo_image[0] : ''; + + // Set our final defaults. + $card_title = $default_title; + $card_description = $default_base_description; + $card_long_description = $default_base_description; + $card_url = $default_url; + $card_image = $logo_url; + $card_type = $default_type; + + // Let's start overriding! + // All singles. + if ( is_singular() ) { + + if ( has_post_thumbnail() ) { + $card_image = get_the_post_thumbnail_url(); + } + } + + // Single posts/pages that aren't the front page. + if ( is_singular() && ! is_front_page() ) { + + $card_title = get_the_title() . ' - ' . $default_title; + $card_description = ( $default_content ) ? wp_trim_words( $default_content, 53, '...' ) : $default_base_description; + $card_long_description = ( $default_content ) ? wp_trim_words( $default_content, 140, '...' ) : $default_base_description; + } + + // Categories, Tags, and Custom Taxonomies. + if ( is_category() || is_tag() || is_tax() ) { + + $term_name = single_term_title( '', false ); + $card_title = $term_name . ' - ' . $default_title; + $specify = ( is_category() ) ? esc_html__( 'categorized in', '_s' ) : esc_html__( 'tagged with', '_s' ); + $queried_object = get_queried_object(); + $card_url = get_term_link( $queried_object ); + $card_type = 'website'; + + // Translators: get the term name. + $card_long_description = sprintf( esc_html__( 'Posts %1$s %2$s.', '_s' ), $specify, $term_name ); + $card_description = $card_long_description; + } + + // Search results. + if ( is_search() ) { + + $search_term = get_search_query(); + $card_title = $search_term . ' - ' . $default_title; + $card_url = get_search_link( $search_term ); + $card_type = 'website'; + + // Translators: get the search term. + $card_long_description = sprintf( esc_html__( 'Search results for %s.', '_s' ), $search_term ); + $card_description = $card_long_description; + } + + if ( is_home() ) { + + $posts_page = get_option( 'page_for_posts' ); + $card_title = get_the_title( $posts_page ) . ' - ' . $default_title; + $card_url = get_permalink( $posts_page ); + $card_type = 'website'; + } + + // Front page. + if ( is_front_page() ) { + + $front_page = get_option( 'page_on_front' ); + $card_title = ( $front_page ) ? get_the_title( $front_page ) . ' - ' . $default_title : $default_title; + $card_url = get_home_url(); + $card_type = 'website'; + } + + // Post type archives. + if ( is_post_type_archive() ) { + + $post_type_name = get_post_type(); + $card_title = $post_type_name . ' - ' . $default_title; + $card_url = get_post_type_archive_link( $post_type_name ); + $card_type = 'website'; + } + + // Media page. + if ( is_attachment() ) { + $attachment_id = get_the_ID(); + $card_image = ( wp_attachment_is_image( $attachment_id ) ) ? wp_get_attachment_image_url( $attachment_id, 'full' ) : $card_image; + } + + ?> + + + + + + + + + + with the_content(); + * + * @author WebDevStudios + * + * @return string Read more link. + * + * @package _s + */ +function _s_content_more_link() { + return ' ' . esc_html__( 'Read More', '_s' ) . '...'; +} + +add_filter( 'the_content_more_link', '_s_content_more_link' ); diff --git a/inc/hooks/custom_mime_types.php b/inc/hooks/custom_mime_types.php new file mode 100644 index 000000000..bfe78f081 --- /dev/null +++ b/inc/hooks/custom_mime_types.php @@ -0,0 +1,20 @@ +%2$s', get_permalink( get_the_ID() ), esc_html__( 'Read more...', '_s' ) ); +} + +add_filter( 'excerpt_more', '_s_excerpt_more' ); diff --git a/inc/hooks/get_the_content.php b/inc/hooks/get_the_content.php new file mode 100644 index 000000000..7202ea990 --- /dev/null +++ b/inc/hooks/get_the_content.php @@ -0,0 +1,17 @@ +'; + require_once $svg_icons; + echo ''; + } +} + +add_action( 'wp_footer', '_s_include_svg_icons', 9999 ); diff --git a/inc/hooks/remove_archive_title_prefix.php b/inc/hooks/remove_archive_title_prefix.php new file mode 100644 index 000000000..ed8edd083 --- /dev/null +++ b/inc/hooks/remove_archive_title_prefix.php @@ -0,0 +1,24 @@ + '', // The scaffolding title. - 'description' => '', // The scaffolding description. - 'usage' => '', // The template tag or markup needed to display the scaffolding. - 'parameters' => [], // Does the scaffolding have params? Like $args? - 'arguments' => [], // If the scaffolding has params, what are the $args? - 'output' => '', // Use the template tag or scaffolding HTML markup here. It will be sanitized displayed. - ]; - - // Parse arguments. - $args = wp_parse_args( $args, $defaults ); - - // Grab our allowed tags. - $allowed_tags = _s_scaffolding_allowed_html(); - - // Add a unique class to the wrapper. - $class = 'scaffolding-' . str_replace( ' ', '-', strtolower( $args['title'] ) ); ?> - -
- -
- -
-

- -
- - -
- -
- - -

:

-

- - - -

:

- $value ) : ?> -

- - - - -

:

- $value ) : ?> -

- - - -
- -
- - -

:

-
- - - -

:

-
- - -
-
-
- -
- - - - - -
-
- - [ - 'aria-hidden' => true, - 'class' => true, - 'id' => true, - 'role' => true, - 'title' => true, - 'fill' => true, - 'height' => true, - 'width' => true, - 'use' => true, - 'path' => true, - ], - 'use' => [ - 'xlink:href' => true, - ], - 'title' => [ - 'id' => true, - ], - 'desc' => [ - 'id' => true, - ], - 'select' => [ - 'class' => true, - ], - 'option' => [ - 'option' => true, - 'value' => true, - 'selected' => true, - 'disabled' => true, - ], - 'input' => [ - 'type' => true, - 'name' => true, - 'value' => true, - 'placeholder' => true, - 'class' => true, - ], - 'iframe' => [ - 'src' => [], - 'height' => [], - 'width' => [], - 'frameborder' => [], - 'allowfullscreen' => [], - ], - ] - ); -} - -/** - * Build a global scaffolding element. - * - * @author Carrie Forde - * - * @param array $args The array of colors or fonts. - */ -function _s_display_global_scaffolding_section( $args = [] ) { - // Set defaults. - $defaults = [ - 'global_type' => '', // Can be 'colors' or 'fonts'. - 'title' => '', // Give the section a title. - 'arguments' => [], // Use key => value pairs to pass colors or fonts. - ]; - - // Parse args. - $args = wp_parse_args( $args, $defaults ); - - // Add a unique class to the wrapper. - $class = 'scaffolding-' . str_replace( ' ', '-', strtolower( $args['title'] ) ); - ?> - -
-
-

-
- -
- - - -
- - $hex ) : - $color_var = '$color-' . str_replace( ' ', '-', strtolower( $name ) ); - ?> - -
-
-
-
- - -
- - - -
- - $family ) : - $font_var = '$font-' . str_replace( ' ', '-', strtolower( $name ) ); - ?> - -

:

- -
- - -
-
- '', // Can be 'colors' or 'fonts'. + 'title' => '', // Give the section a title. + 'arguments' => [], // Use key => value pairs to pass colors or fonts. + ]; + + // Parse args. + $args = wp_parse_args( $args, $defaults ); + + // Add a unique class to the wrapper. + $class = 'scaffolding-' . str_replace( ' ', '-', strtolower( $args['title'] ) ); + ?> + +
+
+

+
+ +
+ + + +
+ + $hex ) : + $color_var = '$color-' . str_replace( ' ', '-', strtolower( $name ) ); + ?> + +
+
+
+
+ + +
+ + + +
+ + $family ) : + $font_var = '$font-' . str_replace( ' ', '-', strtolower( $name ) ); + ?> + +

:

+ +
+ + +
+
+ '', // The scaffolding title. + 'description' => '', // The scaffolding description. + 'usage' => '', // The template tag or markup needed to display the scaffolding. + 'parameters' => [], // Does the scaffolding have params? Like $args? + 'arguments' => [], // If the scaffolding has params, what are the $args? + 'output' => '', // Use the template tag or scaffolding HTML markup here. It will be sanitized displayed. + ]; + + // Parse arguments. + $args = wp_parse_args( $args, $defaults ); + + // Grab our allowed tags. + $allowed_tags = _s_scaffolding_allowed_html(); + + // Add a unique class to the wrapper. + $class = 'scaffolding-' . str_replace( ' ', '-', strtolower( $args['title'] ) ); ?> + +
+ +
+ +
+

+ +
+ + +
+ +
+ + +

:

+

+ + + +

:

+ $value ) : ?> +

+ + + + +

:

+ $value ) : ?> +

+ + + +
+ +
+ + +

:

+
+ + + +

:

+
+ + +
+
+
+ +
+ + + + + +
+
+ + [ + 'aria-hidden' => true, + 'class' => true, + 'id' => true, + 'role' => true, + 'title' => true, + 'fill' => true, + 'height' => true, + 'width' => true, + 'use' => true, + 'path' => true, + ], + 'use' => [ + 'xlink:href' => true, + ], + 'title' => [ + 'id' => true, + ], + 'desc' => [ + 'id' => true, + ], + 'select' => [ + 'class' => true, + ], + 'option' => [ + 'option' => true, + 'value' => true, + 'selected' => true, + 'disabled' => true, + ], + 'input' => [ + 'type' => true, + 'name' => true, + 'value' => true, + 'placeholder' => true, + 'class' => true, + ], + 'iframe' => [ + 'src' => [], + 'height' => [], + 'width' => [], + 'frameborder' => [], + 'allowfullscreen' => [], + ], + ] + ); +} diff --git a/inc/scripts.php b/inc/scripts.php deleted file mode 100644 index 5e050c761..000000000 --- a/inc/scripts.php +++ /dev/null @@ -1,71 +0,0 @@ - '1.0.0', - 'dependencies' => [ 'wp-polyfill' ], - ]; - } - - // Register styles & scripts. - wp_enqueue_style( 'wd_s', get_stylesheet_directory_uri() . '/build/index.css', [], $asset_file['version'] ); - wp_enqueue_script( 'wds-scripts', get_stylesheet_directory_uri() . '/build/index.js', $asset_file['dependencies'], $asset_file['version'], true ); - - if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { - wp_enqueue_script( 'comment-reply' ); - } -} -add_action( 'wp_enqueue_scripts', '_s_scripts' ); - -/** - * Preload styles and scripts. - * - * @author WebDevStudios - */ -function _s_preload_scripts() { - $asset_file_path = dirname( __DIR__ ) . '/build/index.asset.php'; - - if ( is_readable( $asset_file_path ) ) { - $asset_file = include $asset_file_path; - } else { - $asset_file = [ - 'version' => '1.0.0', - 'dependencies' => [ 'wp-polyfill' ], - ]; - } - - ?> - - - - - - - + + + + '1.0.0', + 'dependencies' => [ 'wp-polyfill' ], + ]; + } + + ?> + + + '1.0.0', + 'dependencies' => [ 'wp-polyfill' ], + ]; + } + + // Register styles & scripts. + wp_enqueue_style( 'wd_s', get_stylesheet_directory_uri() . '/build/index.css', [], $asset_file['version'] ); + wp_enqueue_script( 'wds-scripts', get_stylesheet_directory_uri() . '/build/index.js', $asset_file['dependencies'], $asset_file['version'], true ); + + if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { + wp_enqueue_script( 'comment-reply' ); + } +} +add_action( 'wp_enqueue_scripts', '_s_scripts' ); diff --git a/inc/setup.php b/inc/setup/setup.php similarity index 72% rename from inc/setup.php rename to inc/setup/setup.php index 943a21d96..5b4c3d8f2 100644 --- a/inc/setup.php +++ b/inc/setup/setup.php @@ -1,10 +1,4 @@ esc_html__( 'Sidebar 1', '_s' ), - ]; - - // Loop through each sidebar and register. - foreach ( $sidebars as $sidebar_id => $sidebar_name ) { - register_sidebar( - [ - 'name' => $sidebar_name, - 'id' => $sidebar_id, - 'description' => /* translators: the sidebar name */ sprintf( esc_html__( 'Widget area for %s', '_s' ), $sidebar_name ), - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

', - ] - ); - } - -} - -add_action( 'widgets_init', '_s_widgets_init' ); diff --git a/inc/setup/widgets_init.php b/inc/setup/widgets_init.php new file mode 100644 index 000000000..65bec0854 --- /dev/null +++ b/inc/setup/widgets_init.php @@ -0,0 +1,35 @@ + esc_html__( 'Sidebar 1', '_s' ), + ]; + + // Loop through each sidebar and register. + foreach ( $sidebars as $sidebar_id => $sidebar_name ) { + register_sidebar( + [ + 'name' => $sidebar_name, + 'id' => $sidebar_id, + 'description' => /* translators: the sidebar name */ sprintf( esc_html__( 'Widget area for %s', '_s' ), $sidebar_name ), + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + ] + ); + } + +} + +add_action( 'widgets_init', '_s_widgets_init' ); diff --git a/inc/shortcodes/copyright_year.php b/inc/shortcodes/copyright_year.php new file mode 100644 index 000000000..e978cd0d4 --- /dev/null +++ b/inc/shortcodes/copyright_year.php @@ -0,0 +1,33 @@ + '', + 'separator' => ' - ', + ], + $atts + ); + + $current_year = gmdate( 'Y' ); + + // Return current year if starting year is empty. + if ( ! $args['starting_year'] ) { + return $current_year; + } + + return esc_html( $args['starting_year'] . $args['separator'] . $current_year ); +} + +add_shortcode( '_s_copyright_year', '_s_copyright_year', 15 ); diff --git a/inc/template-tags/README.md b/inc/template-tags/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/template-scaffolding.php b/page-templates/scaffolding.php similarity index 100% rename from template-scaffolding.php rename to page-templates/scaffolding.php diff --git a/template-sidebar-right.php b/page-templates/sidebar-right.php similarity index 100% rename from template-sidebar-right.php rename to page-templates/sidebar-right.php From 6b1d8aa7349cbb6b6e4d288fdd6256a7af14d407 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 13 Oct 2021 15:57:00 -0400 Subject: [PATCH 03/65] Replaced underscores with hyphens in filenames --- ..._id_from_url.php => get-attachment-id-from-url.php} | 2 ++ ...t_categorized_blog.php => get-categorized-blog.php} | 10 ++-------- ...get_custom_logo_url.php => get-custom-logo-url.php} | 2 ++ .../{get_the_excerpt.php => get-the-excerpt.php} | 2 ++ inc/functions/{get_the_title.php => get-the-title.php} | 2 ++ inc/hooks/{add_og_tags.php => add-og-tags.php} | 0 inc/hooks/{body_classes.php => body-classes.php} | 0 ...ient_flusher.php => category-transient-flusher.php} | 0 .../{content_more_link.php => content-more-link.php} | 0 .../{custom_mime_types.php => custom-mime-types.php} | 0 ...gutenberg.php => disable-wpautop-for-gutenberg.php} | 0 ...ripts.php => display-customizer-footer-scripts.php} | 0 ...ripts.php => display-customizer-header-scripts.php} | 0 inc/hooks/{excerpt_more.php => excerpt-more.php} | 0 inc/hooks/{get_the_content.php => get-the-content.php} | 0 .../{include_svg_icons.php => include-svg-icons.php} | 0 ...itle_prefix.php => remove-archive-title-prefix.php} | 0 ...tion.php => display-global-scaffolding-section.php} | 0 ...ing_section.php => display-scaffolding-section.php} | 0 ...heme_scaffolding.php => hook-theme-scaffolding.php} | 0 ...g_allowed_html.php => scaffolding-allowed-html.php} | 0 inc/setup/{content_width.php => content-width.php} | 0 inc/setup/{preload_assets.php => preload-assets.php} | 0 inc/setup/{preload_scripts.php => preload-scripts.php} | 0 inc/setup/{widgets_init.php => widgets-init.php} | 0 .../{copyright_year.php => copyright-year.php} | 2 ++ .../{display_comments.php => display-comments.php} | 2 ++ ...y_copyright_text.php => display-copyright-text.php} | 2 ++ ...display_mobile_menu.php => display-mobile-menu.php} | 2 ++ ...c_pagination.php => display-numeric-pagination.php} | 2 ++ ...work_links.php => display-social-network-links.php} | 2 ++ inc/template-tags/{display_svg.php => display-svg.php} | 2 ++ .../{entry_footer.php => entry-footer.php} | 2 ++ inc/template-tags/{get_svg.php => get-svg.php} | 2 ++ inc/template-tags/{posted_on.php => posted-on.php} | 2 ++ 35 files changed, 30 insertions(+), 8 deletions(-) rename inc/functions/{get_attachment_id_from_url.php => get-attachment-id-from-url.php} (98%) rename inc/functions/{get_categorized_blog.php => get-categorized-blog.php} (77%) rename inc/functions/{get_custom_logo_url.php => get-custom-logo-url.php} (95%) rename inc/functions/{get_the_excerpt.php => get-the-excerpt.php} (96%) rename inc/functions/{get_the_title.php => get-the-title.php} (96%) rename inc/hooks/{add_og_tags.php => add-og-tags.php} (100%) rename inc/hooks/{body_classes.php => body-classes.php} (100%) rename inc/hooks/{category_transient_flusher.php => category-transient-flusher.php} (100%) rename inc/hooks/{content_more_link.php => content-more-link.php} (100%) rename inc/hooks/{custom_mime_types.php => custom-mime-types.php} (100%) rename inc/hooks/{disable_wpautop_for_gutenberg.php => disable-wpautop-for-gutenberg.php} (100%) rename inc/hooks/{display_customizer_footer_scripts.php => display-customizer-footer-scripts.php} (100%) rename inc/hooks/{display_customizer_header_scripts.php => display-customizer-header-scripts.php} (100%) rename inc/hooks/{excerpt_more.php => excerpt-more.php} (100%) rename inc/hooks/{get_the_content.php => get-the-content.php} (100%) rename inc/hooks/{include_svg_icons.php => include-svg-icons.php} (100%) rename inc/hooks/{remove_archive_title_prefix.php => remove-archive-title-prefix.php} (100%) rename inc/scaffolding/{display_global_scaffolding_section.php => display-global-scaffolding-section.php} (100%) rename inc/scaffolding/{display_scaffolding_section.php => display-scaffolding-section.php} (100%) rename inc/scaffolding/{hook_theme_scaffolding.php => hook-theme-scaffolding.php} (100%) rename inc/scaffolding/{scaffolding_allowed_html.php => scaffolding-allowed-html.php} (100%) rename inc/setup/{content_width.php => content-width.php} (100%) rename inc/setup/{preload_assets.php => preload-assets.php} (100%) rename inc/setup/{preload_scripts.php => preload-scripts.php} (100%) rename inc/setup/{widgets_init.php => widgets-init.php} (100%) rename inc/shortcodes/{copyright_year.php => copyright-year.php} (97%) rename inc/template-tags/{display_comments.php => display-comments.php} (92%) rename inc/template-tags/{display_copyright_text.php => display-copyright-text.php} (95%) rename inc/template-tags/{display_mobile_menu.php => display-mobile-menu.php} (98%) rename inc/template-tags/{display_numeric_pagination.php => display-numeric-pagination.php} (98%) rename inc/template-tags/{display_social_network_links.php => display-social-network-links.php} (98%) rename inc/template-tags/{display_svg.php => display-svg.php} (98%) rename inc/template-tags/{entry_footer.php => entry-footer.php} (98%) rename inc/template-tags/{get_svg.php => get-svg.php} (99%) rename inc/template-tags/{posted_on.php => posted-on.php} (98%) diff --git a/inc/functions/get_attachment_id_from_url.php b/inc/functions/get-attachment-id-from-url.php similarity index 98% rename from inc/functions/get_attachment_id_from_url.php rename to inc/functions/get-attachment-id-from-url.php index 8121c1e1a..45c8607ce 100644 --- a/inc/functions/get_attachment_id_from_url.php +++ b/inc/functions/get-attachment-id-from-url.php @@ -7,6 +7,8 @@ * @param string $attachment_url The URL of the attachment. * * @return int The attachment ID. + * + * @package _s */ function _s_get_attachment_id_from_url( $attachment_url = '' ) { global $wpdb; diff --git a/inc/functions/get_categorized_blog.php b/inc/functions/get-categorized-blog.php similarity index 77% rename from inc/functions/get_categorized_blog.php rename to inc/functions/get-categorized-blog.php index cd71cb0bd..b83b41c30 100644 --- a/inc/functions/get_categorized_blog.php +++ b/inc/functions/get-categorized-blog.php @@ -1,18 +1,12 @@ %2$s'; From a4be81aaf338f85f6f5c31da09a33d41cf4f78de Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 14 Oct 2021 09:01:42 -0400 Subject: [PATCH 04/65] Added doc block comments --- inc/functions/get-attachment-id-from-url.php | 8 ++++++-- inc/functions/get-categorized-blog.php | 8 ++++++-- inc/functions/get-custom-logo-url.php | 8 ++++++-- inc/functions/get-the-excerpt.php | 8 ++++++-- inc/functions/get-the-title.php | 8 ++++++-- inc/hooks/add-og-tags.php | 8 ++++++-- inc/hooks/body-classes.php | 8 ++++++-- inc/hooks/category-transient-flusher.php | 8 ++++++-- inc/hooks/content-more-link.php | 8 ++++++-- inc/hooks/custom-mime-types.php | 8 ++++++-- inc/hooks/disable-wpautop-for-gutenberg.php | 8 ++++++-- inc/hooks/display-customizer-footer-scripts.php | 8 ++++++-- inc/hooks/display-customizer-header-scripts.php | 8 ++++++-- inc/hooks/excerpt-more.php | 8 ++++++-- inc/hooks/get-the-content.php | 8 ++++++-- inc/hooks/include-svg-icons.php | 8 ++++++-- inc/hooks/remove-archive-title-prefix.php | 8 ++++++-- inc/scaffolding/display-global-scaffolding-section.php | 8 ++++++-- inc/scaffolding/display-scaffolding-section.php | 8 ++++++-- inc/scaffolding/hook-theme-scaffolding.php | 8 ++++++-- inc/scaffolding/scaffolding-allowed-html.php | 8 ++++++-- inc/setup/content-width.php | 8 ++++++-- inc/setup/preload-assets.php | 8 ++++++-- inc/setup/preload-scripts.php | 8 ++++++-- inc/setup/scripts.php | 8 ++++++-- inc/setup/setup.php | 8 ++++++-- inc/setup/widgets-init.php | 8 ++++++-- inc/shortcodes/copyright-year.php | 8 ++++++-- inc/template-tags/display-comments.php | 8 ++++++-- inc/template-tags/display-copyright-text.php | 8 ++++++-- inc/template-tags/display-mobile-menu.php | 8 ++++++-- inc/template-tags/display-numeric-pagination.php | 8 ++++++-- inc/template-tags/display-social-network-links.php | 8 ++++++-- inc/template-tags/display-svg.php | 8 ++++++-- inc/template-tags/entry-footer.php | 8 ++++++-- inc/template-tags/get-svg.php | 8 ++++++-- inc/template-tags/posted-on.php | 8 ++++++-- 37 files changed, 222 insertions(+), 74 deletions(-) diff --git a/inc/functions/get-attachment-id-from-url.php b/inc/functions/get-attachment-id-from-url.php index 45c8607ce..0df2b03be 100644 --- a/inc/functions/get-attachment-id-from-url.php +++ b/inc/functions/get-attachment-id-from-url.php @@ -1,4 +1,10 @@ with the_content(); + * + * @package _s + */ + /** * Customize "Read More" string on with the_content(); * * @author WebDevStudios * * @return string Read more link. - * - * @package _s */ function _s_content_more_link() { return ' ' . esc_html__( 'Read More', '_s' ) . '...'; diff --git a/inc/hooks/custom-mime-types.php b/inc/hooks/custom-mime-types.php index bfe78f081..b6481491a 100644 --- a/inc/hooks/custom-mime-types.php +++ b/inc/hooks/custom-mime-types.php @@ -1,4 +1,10 @@ %2$s', get_permalink( get_the_ID() ), esc_html__( 'Read more...', '_s' ) ); diff --git a/inc/hooks/get-the-content.php b/inc/hooks/get-the-content.php index 7202ea990..c41b51038 100644 --- a/inc/hooks/get-the-content.php +++ b/inc/hooks/get-the-content.php @@ -1,4 +1,10 @@ diff --git a/inc/setup/preload-scripts.php b/inc/setup/preload-scripts.php index 55cee07d7..4485c0901 100644 --- a/inc/setup/preload-scripts.php +++ b/inc/setup/preload-scripts.php @@ -2,10 +2,14 @@ /** * Preload styles and scripts. * - * @author WebDevStudios - * * @package _s */ + +/** + * Preload styles and scripts. + * + * @author WebDevStudios + */ function _s_preload_scripts() { $asset_file_path = dirname( __DIR__ ) . '/build/index.asset.php'; diff --git a/inc/setup/scripts.php b/inc/setup/scripts.php index 420c44df4..431ca2fa7 100644 --- a/inc/setup/scripts.php +++ b/inc/setup/scripts.php @@ -2,10 +2,14 @@ /** * Enqueue scripts and styles. * - * @author WebDevStudios - * * @package _s */ + +/** + * Enqueue scripts and styles. + * + * @author WebDevStudios + */ function _s_scripts() { $asset_file_path = dirname( __DIR__ ) . '/build/index.asset.php'; diff --git a/inc/setup/setup.php b/inc/setup/setup.php index 5b4c3d8f2..e8cfbbf81 100644 --- a/inc/setup/setup.php +++ b/inc/setup/setup.php @@ -1,4 +1,10 @@ %2$s'; From 66c8822b0890ffd4db935645f580b9a92be02541 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 14 Oct 2021 12:27:45 -0400 Subject: [PATCH 05/65] Added readme to inc/ --- inc/README.md | 27 +++++++++++++++++++++++++++ inc/template-tags/README.md | 0 2 files changed, 27 insertions(+) create mode 100644 inc/README.md delete mode 100644 inc/template-tags/README.md diff --git a/inc/README.md b/inc/README.md new file mode 100644 index 000000000..3f1ff9831 --- /dev/null +++ b/inc/README.md @@ -0,0 +1,27 @@ +# Included `PHP` Files + +Use the `/inc` directory to declare any theme functionality. All files in this directory are imported inside of `functions.php`. + +## Directories + +The `/inc` directory is organized into sub-directories based on the functionality/purpose of the code. These directories can be modified as needed, but the following structure is recommended: + +```text +inc/ +└─── customizer/ (functions relating to the theme customizer) +└─── functions/ (general functions that don't fit into any other directory) +└─── hooks/ (theme hooks) +└─── post-types/ (theme post type registrations & functions) +└─── scaffolding/ (theme scaffolding functions) +└─── setup/ (functions relating to the theme setup) +└─── shortcodes/ (shortcode registrations) +└─── template-tags/ (functions that render markup for use in theme templates) +└─── README.md +``` + +## Filenames + +As a general rule, each `.php` file should contain a single function/action which should match the name of the file (replacing underscores with hyphens in the filename). + +For example, `function demo_function() {...}` would be declared in a file named `demo-function.php` and stored inside an appropriate `/inc` sub-directory. + diff --git a/inc/template-tags/README.md b/inc/template-tags/README.md deleted file mode 100644 index e69de29bb..000000000 From 88ec92a353467671d3364afc83a3607d75003a20 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 15 Oct 2021 16:29:18 -0400 Subject: [PATCH 06/65] Working on adding namespaces... --- footer.php | 8 +-- inc/functions/compat.php | 3 ++ ....php => return-attachment-id-from-url.php} | 5 +- ...d-blog.php => return-categorized-blog.php} | 5 +- ...ogo-url.php => return-custom-logo-url.php} | 5 +- .../get-svg.php => functions/return-svg.php} | 17 +++--- ...the-excerpt.php => return-the-excerpt.php} | 5 +- ...get-the-title.php => return-the-title.php} | 5 +- inc/functions/security.php | 6 ++- .../display-scaffolding-section.php | 7 ++- inc/scaffolding/hook-theme-scaffolding.php | 7 ++- inc/scaffolding/scaffolding-allowed-html.php | 5 +- inc/setup/content-width.php | 7 ++- inc/setup/preload-assets.php | 13 +++-- inc/setup/preload-scripts.php | 7 ++- inc/setup/scripts.php | 7 ++- inc/setup/setup.php | 7 ++- inc/setup/widgets-init.php | 7 ++- inc/template-tags/display-comments.php | 5 +- inc/template-tags/display-copyright-text.php | 7 ++- ...ry-footer.php => display-entry-footer.php} | 9 +++- inc/template-tags/display-mobile-menu.php | 5 +- .../display-numeric-pagination.php | 5 +- .../{posted-on.php => display-posted-on.php} | 7 ++- .../display-social-network-links.php | 7 ++- inc/template-tags/display-svg.php | 7 ++- index.php | 4 +- single.php | 8 ++- template-parts/content-search.php | 6 ++- template-parts/content.php | 6 ++- .../scaffolding/scaffolding-buttons.php | 4 +- .../scaffolding/scaffolding-elements.php | 4 +- .../scaffolding/scaffolding-forms.php | 14 ++--- .../scaffolding/scaffolding-icons.php | 11 ++-- .../scaffolding/scaffolding-media.php | 15 +++--- .../scaffolding/scaffolding-typography.php | 54 ++++++++++--------- 36 files changed, 206 insertions(+), 98 deletions(-) rename inc/functions/{get-attachment-id-from-url.php => return-attachment-id-from-url.php} (94%) rename inc/functions/{get-categorized-blog.php => return-categorized-blog.php} (90%) rename inc/functions/{get-custom-logo-url.php => return-custom-logo-url.php} (87%) rename inc/{template-tags/get-svg.php => functions/return-svg.php} (79%) rename inc/functions/{get-the-excerpt.php => return-the-excerpt.php} (87%) rename inc/functions/{get-the-title.php => return-the-title.php} (87%) rename inc/template-tags/{entry-footer.php => display-entry-footer.php} (90%) rename inc/template-tags/{posted-on.php => display-posted-on.php} (94%) diff --git a/footer.php b/footer.php index 6de4cb42e..b33180374 100644 --- a/footer.php +++ b/footer.php @@ -9,6 +9,8 @@ * @package _s */ +namespace WD_S; + ?>
@@ -29,13 +31,13 @@
- - + +
- + diff --git a/inc/functions/compat.php b/inc/functions/compat.php index 69ea889fa..b0adf6605 100644 --- a/inc/functions/compat.php +++ b/inc/functions/compat.php @@ -10,6 +10,9 @@ * * @author WebDevStudios */ + +namespace WD_S\Functions; + if ( ! function_exists( 'wp_body_open' ) ) { /** diff --git a/inc/functions/get-attachment-id-from-url.php b/inc/functions/return-attachment-id-from-url.php similarity index 94% rename from inc/functions/get-attachment-id-from-url.php rename to inc/functions/return-attachment-id-from-url.php index 0df2b03be..b54a769eb 100644 --- a/inc/functions/get-attachment-id-from-url.php +++ b/inc/functions/return-attachment-id-from-url.php @@ -14,7 +14,10 @@ * * @return int The attachment ID. */ -function _s_get_attachment_id_from_url( $attachment_url = '' ) { + +namespace WD_S\Functions; + +function return_attachment_id_from_url( $attachment_url = '' ) { global $wpdb; $attachment_id = false; diff --git a/inc/functions/get-categorized-blog.php b/inc/functions/return-categorized-blog.php similarity index 90% rename from inc/functions/get-categorized-blog.php rename to inc/functions/return-categorized-blog.php index 1837755be..a50643aff 100644 --- a/inc/functions/get-categorized-blog.php +++ b/inc/functions/return-categorized-blog.php @@ -12,7 +12,10 @@ * * @return bool Whether the blog has more than one category. */ -function _s_categorized_blog() { + +namespace WD_S\Functions; + +function return_categorized_blog() { $category_count = get_transient( '_s_categories' ); if ( false === $category_count ) { diff --git a/inc/functions/get-custom-logo-url.php b/inc/functions/return-custom-logo-url.php similarity index 87% rename from inc/functions/get-custom-logo-url.php rename to inc/functions/return-custom-logo-url.php index f555d21b8..ec23a6bf5 100644 --- a/inc/functions/get-custom-logo-url.php +++ b/inc/functions/return-custom-logo-url.php @@ -10,7 +10,10 @@ * * @author Corey Collins */ -function _s_get_custom_logo_url() { + +namespace WD_S\Functions; + +function return_custom_logo_url() { $custom_logo_id = get_theme_mod( 'custom_logo' ); diff --git a/inc/template-tags/get-svg.php b/inc/functions/return-svg.php similarity index 79% rename from inc/template-tags/get-svg.php rename to inc/functions/return-svg.php index a0415a503..480eb0a83 100644 --- a/inc/template-tags/get-svg.php +++ b/inc/functions/return-svg.php @@ -14,7 +14,10 @@ * * @return string Error string or SVG markup. */ -function _s_get_svg( $args = [] ) { + +namespace WD_S\Functions; + +function return_svg( $args = [] ) { // Make sure $args are an array. if ( empty( $args ) ) { return esc_attr__( 'Please define default parameters in the form of an array.', '_s' ); @@ -68,15 +71,15 @@ function _s_get_svg( $args = [] ) { class="icon " role="img"> diff --git a/inc/functions/get-the-excerpt.php b/inc/functions/return-the-excerpt.php similarity index 87% rename from inc/functions/get-the-excerpt.php rename to inc/functions/return-the-excerpt.php index a260ecd32..da9e4b7e2 100644 --- a/inc/functions/get-the-excerpt.php +++ b/inc/functions/return-the-excerpt.php @@ -14,7 +14,10 @@ * * @return string The excerpt. */ -function _s_get_the_excerpt( $args = [] ) { + +namespace WD_S\Functions; + +function return_the_excerpt( $args = [] ) { // Set defaults. $defaults = [ diff --git a/inc/functions/get-the-title.php b/inc/functions/return-the-title.php similarity index 87% rename from inc/functions/get-the-title.php rename to inc/functions/return-the-title.php index a38eb6461..93d9280bd 100644 --- a/inc/functions/get-the-title.php +++ b/inc/functions/return-the-title.php @@ -14,7 +14,10 @@ * * @return string The title. */ -function _s_get_the_title( $args = [] ) { + +namespace WD_S\Functions; + +function return_the_title( $args = [] ) { // Set defaults. $defaults = [ 'length' => 12, diff --git a/inc/functions/security.php b/inc/functions/security.php index aefcd8c69..621fe0d6b 100644 --- a/inc/functions/security.php +++ b/inc/functions/security.php @@ -7,6 +7,8 @@ * @package _s */ +namespace WD_S\Functions; + /** * Remove generator meta tags. * @@ -29,7 +31,7 @@ * @author WebDevStudios * @see https://w3c.github.io/webappsec-cors-for-developers/#avoid-returning-access-control-allow-origin-null */ -function _s_cors_control() { +function cors_control() { header( 'Access-Control-Allow-Origin: *' ); } -add_action( 'rest_api_init', '_s_cors_control' ); +add_action( 'rest_api_init', 'WD_S\Functions\cors_control' ); diff --git a/inc/scaffolding/display-scaffolding-section.php b/inc/scaffolding/display-scaffolding-section.php index 191c3ca40..62c5e2482 100644 --- a/inc/scaffolding/display-scaffolding-section.php +++ b/inc/scaffolding/display-scaffolding-section.php @@ -12,7 +12,10 @@ * * @param array $args The scaffolding defaults. */ -function _s_display_scaffolding_section( $args = [] ) { + +namespace WD_S\Scaffolding; + +function display_scaffolding_section( $args = [] ) { // Set defaults. $defaults = [ 'title' => '', // The scaffolding title. @@ -27,7 +30,7 @@ function _s_display_scaffolding_section( $args = [] ) { $args = wp_parse_args( $args, $defaults ); // Grab our allowed tags. - $allowed_tags = _s_scaffolding_allowed_html(); + $allowed_tags = scaffolding_allowed_html(); // Add a unique class to the wrapper. $class = 'scaffolding-' . str_replace( ' ', '-', strtolower( $args['title'] ) ); ?> diff --git a/inc/scaffolding/hook-theme-scaffolding.php b/inc/scaffolding/hook-theme-scaffolding.php index 5e8a2416e..119a6758f 100644 --- a/inc/scaffolding/hook-theme-scaffolding.php +++ b/inc/scaffolding/hook-theme-scaffolding.php @@ -10,7 +10,10 @@ * * @author Carrie Forde */ -function _s_hook_theme_scaffolding() { + +namespace WD_S\Scaffolding; + +function hook_theme_scaffolding() { $template_dir = 'template-parts/scaffolding/scaffolding'; get_template_part( $template_dir, 'globals' ); @@ -22,4 +25,4 @@ function _s_hook_theme_scaffolding() { get_template_part( $template_dir, 'elements' ); } -add_action( '_s_scaffolding_content', '_s_hook_theme_scaffolding' ); +add_action( '_s_scaffolding_content', 'WD_S\Scaffolding\hook_theme_scaffolding' ); diff --git a/inc/scaffolding/scaffolding-allowed-html.php b/inc/scaffolding/scaffolding-allowed-html.php index d1a66694a..cff4b974a 100644 --- a/inc/scaffolding/scaffolding-allowed-html.php +++ b/inc/scaffolding/scaffolding-allowed-html.php @@ -12,7 +12,10 @@ * * @return array The allowed tags and attributes. */ -function _s_scaffolding_allowed_html() { + +namespace WD_S\Scaffolding; + +function scaffolding_allowed_html() { // Add additional HTML tags to the wp_kses() allowed html filter. return array_merge( wp_kses_allowed_html( 'post' ), diff --git a/inc/setup/content-width.php b/inc/setup/content-width.php index 7ed398ada..536bb08fb 100644 --- a/inc/setup/content-width.php +++ b/inc/setup/content-width.php @@ -14,8 +14,11 @@ * * @author WebDevStudios */ -function _s_content_width() { + +namespace WD_S\Setup; + +function content_width() { $GLOBALS['content_width'] = apply_filters( '_s_content_width', 640 ); } -add_action( 'after_setup_theme', '_s_content_width', 0 ); +add_action( 'after_setup_theme', 'WD_S\Setup\content_width', 0 ); diff --git a/inc/setup/preload-assets.php b/inc/setup/preload-assets.php index 58ff97220..c418aebd1 100644 --- a/inc/setup/preload-assets.php +++ b/inc/setup/preload-assets.php @@ -10,11 +10,16 @@ * * @author Corey Collins */ -function _s_preload_assets() { + +namespace WD_S\Setup; + +use WD_S\Functions as Functions; + +function preload_assets() { ?> - - + + /build/index.js?ver=" as="script"> ' . esc_attr__( 'Posted in %1$s', '_s' ) . '', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- XSS OK. diff --git a/inc/template-tags/display-mobile-menu.php b/inc/template-tags/display-mobile-menu.php index fadaa2b29..9a3057155 100644 --- a/inc/template-tags/display-mobile-menu.php +++ b/inc/template-tags/display-mobile-menu.php @@ -12,7 +12,10 @@ * * @return string An empty string if no menus are found at all. */ -function _s_display_mobile_menu() { + +namespace WD_S\TemplateTags; + +function display_mobile_menu() { // Bail if no mobile or primary menus are set. if ( ! has_nav_menu( 'mobile' ) && ! has_nav_menu( 'primary' ) ) { return ''; diff --git a/inc/template-tags/display-numeric-pagination.php b/inc/template-tags/display-numeric-pagination.php index 70cb3df39..d3951ebd0 100644 --- a/inc/template-tags/display-numeric-pagination.php +++ b/inc/template-tags/display-numeric-pagination.php @@ -13,7 +13,10 @@ * @param array $args Array of params to customize output. * @param WP_Query $query The Query object; only passed if a custom WP_Query is used. */ -function _s_display_numeric_pagination( $args = [], $query = null ) { + +namespace WD_S\TemplateTags; + +function display_numeric_pagination( $args = [], $query = null ) { if ( ! $query ) { global $wp_query; $query = $wp_query; diff --git a/inc/template-tags/posted-on.php b/inc/template-tags/display-posted-on.php similarity index 94% rename from inc/template-tags/posted-on.php rename to inc/template-tags/display-posted-on.php index b33904bae..af1c60acb 100644 --- a/inc/template-tags/posted-on.php +++ b/inc/template-tags/display-posted-on.php @@ -2,7 +2,7 @@ /** * Post date on template function. * - * @package _s + * @package wd_s */ /** @@ -10,7 +10,10 @@ * * @author WebDevStudios */ -function _s_posted_on() { + +namespace WD_S\TemplateTags; + +function display_posted_on() { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; diff --git a/inc/template-tags/display-social-network-links.php b/inc/template-tags/display-social-network-links.php index 1bfce4390..dc8df5c60 100644 --- a/inc/template-tags/display-social-network-links.php +++ b/inc/template-tags/display-social-network-links.php @@ -10,7 +10,10 @@ * * @author WebDevStudios */ -function _s_display_social_network_links() { + +namespace WD_S\TemplateTags; + +function display_social_network_links() { // Create an array of our social links for ease of setup. // Change the order of the networks in this array to change the output order. $social_networks = [ @@ -35,7 +38,7 @@ function _s_display_social_network_links() {