Skip to content

Commit

Permalink
Fix PHP, CSS AND JS coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismail-elkorchi committed Apr 5, 2020
1 parent 2351bef commit f94fc1e
Show file tree
Hide file tree
Showing 42 changed files with 357 additions and 213 deletions.
16 changes: 9 additions & 7 deletions 404.php
Expand Up @@ -31,13 +31,15 @@
<h2 class="widget-title"><?php esc_html_e( 'Most Used Categories', '_s' ); ?></h2>
<ul>
<?php
wp_list_categories( array(
'orderby' => 'count',
'order' => 'DESC',
'show_count' => 1,
'title_li' => '',
'number' => 10,
) );
wp_list_categories(
array(
'orderby' => 'count',
'order' => 'DESC',
'show_count' => 1,
'title_li' => '',
'number' => 10,
)
);
?>
</ul>
</div><!-- .widget -->
Expand Down
14 changes: 8 additions & 6 deletions comments.php
Expand Up @@ -36,10 +36,10 @@
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
);
} else {
printf( // WPCS: XSS OK.
printf(
/* translators: 1: comment count number, 2: title. */
esc_html( _nx( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', $_s_comment_count, 'comments title', '_s' ) ),
number_format_i18n( $_s_comment_count ),
number_format_i18n( $_s_comment_count ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
);
}
Expand All @@ -50,10 +50,12 @@

<ol class="comment-list">
<?php
wp_list_comments( array(
'style' => 'ol',
'short_ping' => true,
) );
wp_list_comments(
array(
'style' => 'ol',
'short_ping' => true,
)
);
?>
</ol><!-- .comment-list -->

Expand Down
85 changes: 53 additions & 32 deletions functions.php
Expand Up @@ -7,6 +7,11 @@
* @package _s
*/

if ( ! defined( '_S_VERSION' ) ) {
// Replace #.# with the version number of the theme on each release.
define( '_S_VERSION', '#.#' );
}

if ( ! function_exists( '_s_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
Expand Down Expand Up @@ -43,27 +48,38 @@ function _s_setup() {
add_theme_support( 'post-thumbnails' );

// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'menu-1' => esc_html__( 'Primary', '_s' ),
) );
register_nav_menus(
array(
'menu-1' => esc_html__( 'Primary', '_s' ),
)
);

/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);

// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( '_s_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
add_theme_support(
'custom-background',
apply_filters(
'_s_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);

// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
Expand All @@ -73,12 +89,15 @@ function _s_setup() {
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
) );
add_theme_support(
'custom-logo',
array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
}
endif;
add_action( 'after_setup_theme', '_s_setup' );
Expand All @@ -104,27 +123,29 @@ function _s_content_width() {
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function _s_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', '_s' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', '_s' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', '_s' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', '_s' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
}
add_action( 'widgets_init', '_s_widgets_init' );

/**
* Enqueue scripts and styles.
*/
function _s_scripts() {
wp_enqueue_style( '_s-style', get_stylesheet_uri() );
wp_enqueue_style( '_s-style', get_stylesheet_uri(), array(), _S_VERSION );

wp_enqueue_script( '_s-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( '_s-navigation', get_template_directory_uri() . '/js/navigation.js', array(), _S_VERSION, true );

wp_enqueue_script( '_s-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
wp_enqueue_script( '_s-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), _S_VERSION, true );

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
Expand Down
12 changes: 7 additions & 5 deletions header.php
Expand Up @@ -41,17 +41,19 @@
$_s_description = get_bloginfo( 'description', 'display' );
if ( $_s_description || is_customize_preview() ) :
?>
<p class="site-description"><?php echo $_s_description; /* WPCS: xss ok. */ ?></p>
<p class="site-description"><?php echo $_s_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php endif; ?>
</div><!-- .site-branding -->

<nav id="site-navigation" class="main-navigation">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Primary Menu', '_s' ); ?></button>
<?php
wp_nav_menu( array(
'theme_location' => 'menu-1',
'menu_id' => 'primary-menu',
) );
wp_nav_menu(
array(
'theme_location' => 'menu-1',
'menu_id' => 'primary-menu',
)
);
?>
</nav><!-- #site-navigation -->
</header><!-- #masthead -->
Expand Down
22 changes: 14 additions & 8 deletions inc/custom-header.php
Expand Up @@ -17,14 +17,20 @@
* @uses _s_header_style()
*/
function _s_custom_header_setup() {
add_theme_support( 'custom-header', apply_filters( '_s_custom_header_args', array(
'default-image' => '',
'default-text-color' => '000000',
'width' => 1000,
'height' => 250,
'flex-height' => true,
'wp-head-callback' => '_s_header_style',
) ) );
add_theme_support(
'custom-header',
apply_filters(
'_s_custom_header_args',
array(
'default-image' => '',
'default-text-color' => '000000',
'width' => 1000,
'height' => 250,
'flex-height' => true,
'wp-head-callback' => '_s_header_style',
)
)
);
}
add_action( 'after_setup_theme', '_s_custom_header_setup' );

Expand Down
22 changes: 14 additions & 8 deletions inc/customizer.php
Expand Up @@ -16,14 +16,20 @@ function _s_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';

if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => '_s_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => '_s_customize_partial_blogdescription',
) );
$wp_customize->selective_refresh->add_partial(
'blogname',
array(
'selector' => '.site-title a',
'render_callback' => '_s_customize_partial_blogname',
)
);
$wp_customize->selective_refresh->add_partial(
'blogdescription',
array(
'selector' => '.site-description',
'render_callback' => '_s_customize_partial_blogdescription',
)
);
}
}
add_action( 'customize_register', '_s_customize_register' );
Expand Down
46 changes: 26 additions & 20 deletions inc/jetpack.php
Expand Up @@ -16,31 +16,37 @@
*/
function _s_jetpack_setup() {
// Add theme support for Infinite Scroll.
add_theme_support( 'infinite-scroll', array(
'container' => 'main',
'render' => '_s_infinite_scroll_render',
'footer' => 'page',
) );
add_theme_support(
'infinite-scroll',
array(
'container' => 'main',
'render' => '_s_infinite_scroll_render',
'footer' => 'page',
)
);

// Add theme support for Responsive Videos.
add_theme_support( 'jetpack-responsive-videos' );

// Add theme support for Content Options.
add_theme_support( 'jetpack-content-options', array(
'post-details' => array(
'stylesheet' => '_s-style',
'date' => '.posted-on',
'categories' => '.cat-links',
'tags' => '.tags-links',
'author' => '.byline',
'comment' => '.comments-link',
),
'featured-images' => array(
'archive' => true,
'post' => true,
'page' => true,
),
) );
add_theme_support(
'jetpack-content-options',
array(
'post-details' => array(
'stylesheet' => '_s-style',
'date' => '.posted-on',
'categories' => '.cat-links',
'tags' => '.tags-links',
'author' => '.byline',
'comment' => '.comments-link',
),
'featured-images' => array(
'archive' => true,
'post' => true,
'page' => true,
),
)
);
}
add_action( 'after_setup_theme', '_s_jetpack_setup' );

Expand Down

0 comments on commit f94fc1e

Please sign in to comment.