This commit is contained in:
Ben Goldsworthy 2021-01-23 13:41:03 +00:00
parent d80cbb4c32
commit aba542d60d

View file

@ -114,7 +114,12 @@ if ( ! function_exists( 'omphaloskepsis_setup' ) ) :
* This theme styles the visual editor to resemble the theme style, * This theme styles the visual editor to resemble the theme style,
* specifically font, colors, icons, and column width. * specifically font, colors, icons, and column width.
*/ */
add_editor_style( array( 'css/editor-style.css', omphaloskepsis_fonts_url() ) ); add_editor_style(
array(
'css/editor-style.css',
omphaloskepsis_fonts_url(),
)
);
// Indicate widget sidebars can use selective refresh in the Customizer. // Indicate widget sidebars can use selective refresh in the Customizer.
add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'customize-selective-refresh-widgets' );
@ -243,8 +248,7 @@ add_action( 'wp_head', 'omphaloskepsis_javascript_detection', 0 );
* *
* @since Omphaloskepsis 1.0 * @since Omphaloskepsis 1.0
*/ */
function omphaloskepsis_scripts() { function omphaloskepsis_scripts() { // phpcs:disable WordPress.WP.EnqueuedResourceParameters
// phpcs:disable WordPress.WP.EnqueuedResourceParameters
// Load the normalisation stylesheet. // Load the normalisation stylesheet.
wp_enqueue_style( 'omphaloskepsis-reset', get_template_directory_uri() . '/css/reset.css', array() ); wp_enqueue_style( 'omphaloskepsis-reset', get_template_directory_uri() . '/css/reset.css', array() );
@ -263,15 +267,36 @@ function omphaloskepsis_scripts() {
wp_enqueue_style( 'montserrat', 'https://fonts.googleapis.com/css?family=Montserrat' ); wp_enqueue_style( 'montserrat', 'https://fonts.googleapis.com/css?family=Montserrat' );
// Load the Internet Explorer specific stylesheet. // Load the Internet Explorer specific stylesheet.
wp_enqueue_style( 'omphaloskepsis-ie', get_template_directory_uri() . '/css/ie.css', array( 'omphaloskepsis-style' ), '20160412' ); wp_enqueue_style(
'omphaloskepsis-ie',
get_template_directory_uri() . '/css/ie.css',
array(
'omphaloskepsis-style',
),
'20160412'
);
wp_style_add_data( 'omphaloskepsis-ie', 'conditional', 'lt IE 10' ); wp_style_add_data( 'omphaloskepsis-ie', 'conditional', 'lt IE 10' );
// Load the Internet Explorer 8 specific stylesheet. // Load the Internet Explorer 8 specific stylesheet.
wp_enqueue_style( 'omphaloskepsis-ie8', get_template_directory_uri() . '/css/ie8.css', array( 'omphaloskepsis-style' ), '20160412' ); wp_enqueue_style(
'omphaloskepsis-ie8',
get_template_directory_uri() . '/css/ie8.css',
array(
'omphaloskepsis-style',
),
'20160412'
);
wp_style_add_data( 'omphaloskepsis-ie8', 'conditional', 'lt IE 9' ); wp_style_add_data( 'omphaloskepsis-ie8', 'conditional', 'lt IE 9' );
// Load the Internet Explorer 7 specific stylesheet. // Load the Internet Explorer 7 specific stylesheet.
wp_enqueue_style( 'omphaloskepsis-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'omphaloskepsis-style' ), '20160412' ); wp_enqueue_style(
'omphaloskepsis-ie7',
get_template_directory_uri() . '/css/ie7.css',
array(
'omphaloskepsis-style',
),
'20160412'
);
wp_style_add_data( 'omphaloskepsis-ie7', 'conditional', 'lt IE 8' ); wp_style_add_data( 'omphaloskepsis-ie7', 'conditional', 'lt IE 8' );
// Load the html5 shiv. // Load the html5 shiv.
@ -285,10 +310,25 @@ function omphaloskepsis_scripts() {
} }
if ( is_singular() && wp_attachment_is_image() ) { if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'omphaloskepsis-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20160412' ); wp_enqueue_script(
'omphaloskepsis-keyboard-image-navigation',
get_template_directory_uri() . '/js/keyboard-image-navigation.js',
array(
'jquery',
),
'20160412'
);
} }
wp_enqueue_script( 'omphaloskepsis-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20160412', true ); wp_enqueue_script(
'omphaloskepsis-script',
get_template_directory_uri() . '/js/functions.js',
array(
'jquery',
),
'20160412',
true
);
wp_localize_script( wp_localize_script(
'omphaloskepsis-script', 'omphaloskepsis-script',
@ -299,6 +339,7 @@ function omphaloskepsis_scripts() {
) )
); );
// phpcs:enable // phpcs:enable
} }
add_action( 'wp_enqueue_scripts', 'omphaloskepsis_scripts' ); add_action( 'wp_enqueue_scripts', 'omphaloskepsis_scripts' );
@ -366,7 +407,6 @@ function omphaloskepsis_hex2rgb( $color ) {
); );
} }
/** /**
* Add custom image sizes attribute to enhance responsive image functionality * Add custom image sizes attribute to enhance responsive image functionality
* for content images * for content images
@ -533,7 +573,9 @@ function display_companies() {
array( array(
'having_images' => false, 'having_images' => false,
'taxonomy' => 'company', 'taxonomy' => 'company',
'term_args' => array( 'parent' => 0 ), 'term_args' => array(
'parent' => 0,
),
) )
); );
$include = 1; $include = 1;
@ -550,7 +592,6 @@ function display_companies() {
$include = 0; $include = 0;
} }
// phpcs:enable // phpcs:enable
if ( ! empty( $terms ) ) { if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) { foreach ( $terms as $term ) {
$term_children = get_term_children( $term->term_id, 'company' ); $term_children = get_term_children( $term->term_id, 'company' );
@ -564,8 +605,28 @@ function display_companies() {
// 6 = Others // 6 = Others
// 7 = Qualifications // 7 = Qualifications
// 8 = Awards // 8 = Awards
$post_types = array( 'job', 'post', 'website', 'program', 'writing', 'video', 'other', 'qualification', 'award' ); $post_types = array(
$dashicons = array( 'hammer', 'admin-post', 'schedule', 'desktop', 'format-aside', 'video-alt', 'archive', 'id', 'awards' ); 'job',
'post',
'website',
'program',
'writing',
'video',
'other',
'qualification',
'award',
);
$dashicons = array(
'hammer',
'admin-post',
'schedule',
'desktop',
'format-aside',
'video-alt',
'archive',
'id',
'awards',
);
$term_items = array(); $term_items = array();
$term_item_counts = array(); $term_item_counts = array();
@ -573,7 +634,7 @@ function display_companies() {
// phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_query // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_query
foreach ( $post_types as $post_type ) { foreach ( $post_types as $post_type ) {
$args = array( $args = array(
'posts_per_page' => -1, 'posts_per_page' => - 1,
'post_type' => $post_type, 'post_type' => $post_type,
'tax_query' => array( 'tax_query' => array(
array( array(
@ -606,23 +667,14 @@ function display_companies() {
); );
} }
// phpcs:enable // phpcs:enable
$posts = get_posts( $args ); $posts = get_posts( $args );
array_push( $term_items, $posts ); array_push( $term_items, $posts );
array_push( $term_item_counts, count( $posts ) ); array_push( $term_item_counts, count( $posts ) );
} }
if ( ( isset( $_POST['job'] ) && 'true' === $_POST['job'] && $term_item_counts[0] > 0 ) || if ( ( isset( $_POST['job'] ) && 'true' === $_POST['job'] && $term_item_counts[0] > 0 ) || ( isset( $_POST['post'] ) && 'true' === $_POST['post'] && $term_item_counts[1] > 0 ) || ( isset( $_POST['website'] ) && 'true' === $_POST['website'] && $term_item_counts[2] > 0 ) || ( isset( $_POST['program'] ) && 'true' === $_POST['program'] && $term_item_counts[3] > 0 ) || ( isset( $_POST['writing'] ) && 'true' === $_POST['writing'] && $term_item_counts[4] > 0 ) || ( isset( $_POST['video'] ) && 'true' === $_POST['video'] && $term_item_counts[5] > 0 ) || ( isset( $_POST['other'] ) && 'true' === $_POST['other'] && $term_item_counts[6] > 0 ) || ( isset( $_POST['qualification'] ) && 'true' === $_POST['qualification'] && $term_item_counts[7] > 0 ) || ( isset( $_POST['award'] ) && 'true' === $_POST['award'] && $term_item_counts[8] > 0 ) ) {
( isset( $_POST['post'] ) && 'true' === $_POST['post'] && $term_item_counts[1] > 0 ) || $img_url = wp_get_attachment_image_src( $term->image_id, 'full' ) [0];
( isset( $_POST['website'] ) && 'true' === $_POST['website'] && $term_item_counts[2] > 0 ) ||
( isset( $_POST['program'] ) && 'true' === $_POST['program'] && $term_item_counts[3] > 0 ) ||
( isset( $_POST['writing'] ) && 'true' === $_POST['writing'] && $term_item_counts[4] > 0 ) ||
( isset( $_POST['video'] ) && 'true' === $_POST['video'] && $term_item_counts[5] > 0 ) ||
( isset( $_POST['other'] ) && 'true' === $_POST['other'] && $term_item_counts[6] > 0 ) ||
( isset( $_POST['qualification'] ) && 'true' === $_POST['qualification'] && $term_item_counts[7] > 0 ) ||
( isset( $_POST['award'] ) && 'true' === $_POST['award'] && $term_item_counts[8] > 0 ) ) {
$img_url = wp_get_attachment_image_src( $term->image_id, 'full' )[0];
$bg_img = ( ! $img_url ) ? '' : ' background-image: url(' . strtok( $img_url, '?' ) . ');'; $bg_img = ( ! $img_url ) ? '' : ' background-image: url(' . strtok( $img_url, '?' ) . ');';
$colour = get_term_meta( $term->term_id, 'color', true ); $colour = get_term_meta( $term->term_id, 'color', true );
$colour = ( '' !== $colour ) ? $colour : 'transparent'; $colour = ( '' !== $colour ) ? $colour : 'transparent';
@ -677,3 +729,5 @@ remove_filter( 'term_description', 'wp_kses_data' );
// honour user DNT header. // honour user DNT header.
add_filter( 'jetpack_honor_dnt_header_for_stats', '__return_true' ); add_filter( 'jetpack_honor_dnt_header_for_stats', '__return_true' );