From c9c0286a17035130cb7cf047d57b184d32640620 Mon Sep 17 00:00:00 2001 From: Leo Germani Date: Mon, 27 Aug 2018 16:24:39 -0300 Subject: [PATCH] Adjusting theme to WordPress.org --- composer.json | 1 - install.sh | 8 - src/functions.php | 2 +- src/functions/pagination.php | 4 +- src/functions/single-functions.php | 2 +- src/header.php | 10 - src/lib/class-wp-bootstrap-navwalker.php | 555 +++++++++++++++++++++++ src/single-colecoes.php | 166 ------- 8 files changed, 559 insertions(+), 189 deletions(-) create mode 100644 src/lib/class-wp-bootstrap-navwalker.php delete mode 100644 src/single-colecoes.php diff --git a/composer.json b/composer.json index 7a4971b..26a97dd 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,6 @@ ], "require": { "twbs/bootstrap": "4.*", - "wp-bootstrap/wp-bootstrap-navwalker": "*", "fabianobn/slick": "v1.8.*" }, "scripts": { diff --git a/install.sh b/install.sh index f9452d9..702d768 100644 --- a/install.sh +++ b/install.sh @@ -4,14 +4,6 @@ echo "\n ..::Tainacan Theme::..\n"; echo "\nStarting installation with composer ... please wait!!\n"; -echo "\n Checking if file bootstrap navwalker exist ... \n\n"; - -if (!file_exists("src/vendor/class-wp-bootstrap-navwalker.php")) { - echo "\m Copy Boostrap Navwalker ... \n\n"; - mkdir("src/vendor/", 0777, true); - copy("vendor/wp-bootstrap/wp-bootstrap-navwalker/class-wp-bootstrap-navwalker.php", "src/vendor/class-wp-bootstrap-navwalker.php"); -} - echo "\nStarting Copying Files...\n\n"; echo "\nCopy Frameword CSS - Bootstrap ...\n\n"; diff --git a/src/functions.php b/src/functions.php index c64753f..0dd8bf1 100644 --- a/src/functions.php +++ b/src/functions.php @@ -152,7 +152,7 @@ add_filter( 'get_custom_logo', 'tainacan_change_logo_class' ); /** * Class navwalker */ -require_once get_template_directory() . '/vendor/class-wp-bootstrap-navwalker.php'; +require_once get_template_directory() . '/lib/class-wp-bootstrap-navwalker.php'; /** * Register the menu for use after the banner diff --git a/src/functions/pagination.php b/src/functions/pagination.php index 17cb91a..b2661ec 100644 --- a/src/functions/pagination.php +++ b/src/functions/pagination.php @@ -52,7 +52,7 @@ printf( '%s' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' ); if ( ! in_array( 2, $links ) ) - echo '
  • '; + echo '
  • '; } /** Link to current page, plus 2 pages in either direction if necessary */ @@ -65,7 +65,7 @@ /** Link to last page, plus ellipses if necessary */ if ( ! in_array( $max, $links ) ) { if ( ! in_array( $max - 1, $links ) ) - echo '
  • ' . "\n"; + echo '
  • ' . "\n"; $class = $paged == $max ? ' class="active"' : ''; printf( '%s' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max ); diff --git a/src/functions/single-functions.php b/src/functions/single-functions.php index 6e539d7..3dfd20f 100644 --- a/src/functions/single-functions.php +++ b/src/functions/single-functions.php @@ -22,7 +22,7 @@ function tainacan_Comments_Callback($comment, $args, $depth) { comment_ID ); ?> %s às %s.

    ', get_comment_date(), get_comment_time()); + printf('

    %s às %s.

    ', get_comment_date(), get_comment_time()); ?> comment_approved) : ?> diff --git a/src/header.php b/src/header.php index dff8b28..fd0ef1b 100644 --- a/src/header.php +++ b/src/header.php @@ -33,16 +33,6 @@ - \ No newline at end of file diff --git a/src/lib/class-wp-bootstrap-navwalker.php b/src/lib/class-wp-bootstrap-navwalker.php new file mode 100644 index 0000000..7f33845 --- /dev/null +++ b/src/lib/class-wp-bootstrap-navwalker.php @@ -0,0 +1,555 @@ +item_spacing ) && 'discard' === $args->item_spacing ) { + $t = ''; + $n = ''; + } else { + $t = "\t"; + $n = "\n"; + } + $indent = str_repeat( $t, $depth ); + // Default class to add to the file. + $classes = array( 'dropdown-menu' ); + /** + * Filters the CSS class(es) applied to a menu list element. + * + * @since WP 4.8.0 + * + * @param array $classes The CSS classes that are applied to the menu `'; + if ( $container ) { + $fallback_output .= ''; + } + + // if $args has 'echo' key and it's true echo, otherwise return. + if ( array_key_exists( 'echo', $args ) && $args['echo'] ) { + echo $fallback_output; // WPCS: XSS OK. + } else { + return $fallback_output; + } + } + } + + /** + * Find any custom linkmod or icon classes and store in their holder + * arrays then remove them from the main classes array. + * + * Supported linkmods: .disabled, .dropdown-header, .dropdown-divider, .sr-only + * Supported iconsets: Font Awesome 4/5, Glypicons + * + * NOTE: This accepts the linkmod and icon arrays by reference. + * + * @since 4.0.0 + * + * @param array $classes an array of classes currently assigned to the item. + * @param array $linkmod_classes an array to hold linkmod classes. + * @param array $icon_classes an array to hold icon classes. + * @param integer $depth an integer holding current depth level. + * + * @return array $classes a maybe modified array of classnames. + */ + private function seporate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) { + // Loop through $classes array to find linkmod or icon classes. + foreach ( $classes as $key => $class ) { + // If any special classes are found, store the class in it's + // holder array and and unset the item from $classes. + if ( preg_match( '/^disabled|^sr-only/i', $class ) ) { + // Test for .disabled or .sr-only classes. + $linkmod_classes[] = $class; + unset( $classes[ $key ] ); + } elseif ( preg_match( '/^dropdown-header|^dropdown-divider|^dropdown-item-text/i', $class ) && $depth > 0 ) { + // Test for .dropdown-header or .dropdown-divider and a + // depth greater than 0 - IE inside a dropdown. + $linkmod_classes[] = $class; + unset( $classes[ $key ] ); + } elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/i', $class ) ) { + // Font Awesome. + $icon_classes[] = $class; + unset( $classes[ $key ] ); + } elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/i', $class ) ) { + // Glyphicons. + $icon_classes[] = $class; + unset( $classes[ $key ] ); + } + } + + return $classes; + } + + /** + * Return a string containing a linkmod type and update $atts array + * accordingly depending on the decided. + * + * @since 4.0.0 + * + * @param array $linkmod_classes array of any link modifier classes. + * + * @return string empty for default, a linkmod type string otherwise. + */ + private function get_linkmod_type( $linkmod_classes = array() ) { + $linkmod_type = ''; + // Loop through array of linkmod classes to handle their $atts. + if ( ! empty( $linkmod_classes ) ) { + foreach ( $linkmod_classes as $link_class ) { + if ( ! empty( $link_class ) ) { + + // check for special class types and set a flag for them. + if ( 'dropdown-header' === $link_class ) { + $linkmod_type = 'dropdown-header'; + } elseif ( 'dropdown-divider' === $link_class ) { + $linkmod_type = 'dropdown-divider'; + } elseif ( 'dropdown-item-text' === $link_class ) { + $linkmod_type = 'dropdown-item-text'; + } + } + } + } + return $linkmod_type; + } + + /** + * Update the attributes of a nav item depending on the limkmod classes. + * + * @since 4.0.0 + * + * @param array $atts array of atts for the current link in nav item. + * @param array $linkmod_classes an array of classes that modify link or nav item behaviors or displays. + * + * @return array maybe updated array of attributes for item. + */ + private function update_atts_for_linkmod_type( $atts = array(), $linkmod_classes = array() ) { + if ( ! empty( $linkmod_classes ) ) { + foreach ( $linkmod_classes as $link_class ) { + if ( ! empty( $link_class ) ) { + // update $atts with a space and the extra classname... + // so long as it's not a sr-only class. + if ( 'sr-only' !== $link_class ) { + $atts['class'] .= ' ' . esc_attr( $link_class ); + } + // check for special class types we need additional handling for. + if ( 'disabled' === $link_class ) { + // Convert link to '#' and unset open targets. + $atts['href'] = '#'; + unset( $atts['target'] ); + } elseif ( 'dropdown-header' === $link_class || 'dropdown-divider' === $link_class || 'dropdown-item-text' === $link_class ) { + // Store a type flag and unset href and target. + unset( $atts['href'] ); + unset( $atts['target'] ); + } + } + } + } + return $atts; + } + + /** + * Wraps the passed text in a screen reader only class. + * + * @since 4.0.0 + * + * @param string $text the string of text to be wrapped in a screen reader class. + * @return string the string wrapped in a span with the class. + */ + private function wrap_for_screen_reader( $text = '' ) { + if ( $text ) { + $text = '' . $text . ''; + } + return $text; + } + + /** + * Returns the correct opening element and attributes for a linkmod. + * + * @since 4.0.0 + * + * @param string $linkmod_type a sting containing a linkmod type flag. + * @param string $attributes a string of attributes to add to the element. + * + * @return string a string with the openign tag for the element with attribibutes added. + */ + private function linkmod_element_open( $linkmod_type, $attributes = '' ) { + $output = ''; + if ( 'dropdown-item-text' === $linkmod_type ) { + $output .= ''; + } elseif ( 'dropdown-header' === $linkmod_type ) { + // For a header use a span with the .h6 class instead of a real + // header tag so that it doesn't confuse screen readers. + $output .= ''; + } elseif ( 'dropdown-divider' === $linkmod_type ) { + // this is a divider. + $output .= ''; + } + return $output; + } + } +} diff --git a/src/single-colecoes.php b/src/single-colecoes.php deleted file mode 100644 index 5041ea7..0000000 --- a/src/single-colecoes.php +++ /dev/null @@ -1,166 +0,0 @@ - -
    - -
    -
    -
    -

    About

    -

    about text

    -
    -
    -
    -
    -

    Hiring Info

    -

    info text

    -
    -
    -
    -
    -
    -

    Rankings

    Ver mais -
    -
    -
    - Esculturas -
    -
    - Livros -
    -
    - Quadros -
    -
    -
    - Artefatos -
    -
    - Documentos -
    -
    - Outros -
    -
    -
    -
    -
    -

    Imagens em destaque

    Ver mais -
    -
    - - -
    -
    - -
    -
    -

    Estatísticas

    Ver mais -
    -
    -
    -
    Localização do usuário
    -
    - -
    -
    -
    -
    Coleções do usuário
    -
    -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -

    Características

    Ver mais -
    -
    - -
    -
    -
    - - \ No newline at end of file