/i', '$1$2 itemprop=$2item$2>', $item )
: sprintf( '%s', $item );
// Add list item classes.
$item_class = 'trail-item';
if ( 1 === $item_position && 1 < $item_count ) {
$item_class .= ' trail-begin';
} elseif ( $item_count === $item_position ) {
$item_class .= ' trail-end';
}
// Create list item attributes.
$attributes = 'itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem" class="' . $item_class . '"';
// Build the meta position HTML.
$meta = sprintf( '', absint( $item_position ) );
// Build the list item.
$breadcrumb .= sprintf( '<%1$s %2$s>%3$s%4$s%1$s>', tag_escape( $this->args['item_tag'] ), $attributes, $item, $meta );
}
// Close the unordered list.
$breadcrumb .= sprintf( '%s>', tag_escape( $this->args['list_tag'] ) );
// Wrap the breadcrumb trail.
$breadcrumb = sprintf(
'<%1$s role="navigation" aria-label="%2$s" class="breadcrumb-trail breadcrumbs" itemprop="breadcrumb">%3$s%4$s%5$s%1$s>',
tag_escape( $this->args['container'] ),
esc_attr( $this->labels['aria_label'] ),
$this->args['before'],
$breadcrumb,
$this->args['after']
);
}
// Allow developers to filter the breadcrumb trail HTML.
$breadcrumb = apply_filters( 'sinatra_breadcrumb_trail', $breadcrumb, $this->args );
if ( false === $this->args['echo'] ) {
return $breadcrumb;
}
echo $breadcrumb; // phpcs:ignore
}
/* ====== Protected Methods ====== */
/**
* Sets the labels property. Parses the inputted labels array with the defaults.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function set_labels() {
$defaults = array(
'browse' => esc_html__( 'Browse:', 'sinatra' ),
'aria_label' => esc_attr_x( 'Breadcrumbs', 'breadcrumbs aria label', 'sinatra' ),
'home' => esc_html__( 'Home', 'sinatra' ),
'error_404' => esc_html__( '404 Not Found', 'sinatra' ),
'archives' => esc_html__( 'Archives', 'sinatra' ),
// Translators: %s is the search query.
'search' => esc_html__( 'Search results for: %s', 'sinatra' ),
// Translators: %s is the page number.
'paged' => esc_html__( 'Page %s', 'sinatra' ),
// Translators: %s is the page number.
'paged_comments' => esc_html__( 'Comment Page %s', 'sinatra' ),
// Translators: Minute archive title. %s is the minute time format.
'archive_minute' => esc_html__( 'Minute %s', 'sinatra' ),
// Translators: Weekly archive title. %s is the week date format.
'archive_week' => esc_html__( 'Week %s', 'sinatra' ),
// "%s" is replaced with the translated date/time format.
'archive_minute_hour' => '%s',
'archive_hour' => '%s',
'archive_day' => '%s',
'archive_month' => '%s',
'archive_year' => '%s',
);
$this->labels = apply_filters( 'sinatra_breadcrumb_trail_labels', wp_parse_args( $this->args['labels'], $defaults ) );
}
/**
* Sets the `$post_taxonomy` property. This is an array of post types (key) and taxonomies (value).
* The taxonomy's terms are shown on the singular post view if set.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function set_post_taxonomy() {
$defaults = array();
// If post permalink is set to `%postname%`, use the `category` taxonomy.
if ( '%postname%' === trim( get_option( 'permalink_structure' ), '/' ) ) {
$defaults['post'] = 'category';
}
$this->post_taxonomy = apply_filters( 'sinatra_breadcrumb_trail_post_taxonomy', wp_parse_args( $this->args['post_taxonomy'], $defaults ) );
}
/**
* Runs through the various WordPress conditional tags to check the current page being viewed. Once
* a condition is met, a specific method is launched to add items to the `$items` array.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_items() {
if ( is_front_page() ) {
$this->add_front_page_items();
} else {
// Add the network and site home links.
$this->add_network_home_link();
$this->add_site_home_link();
if ( is_home() ) {
$this->add_blog_items();
} elseif ( is_singular() ) {
$this->add_singular_items();
} elseif ( is_archive() ) {
if ( is_post_type_archive() ) {
$this->add_post_type_archive_items();
} elseif ( is_category() || is_tag() || is_tax() ) {
$this->add_term_archive_items();
} elseif ( is_author() ) {
$this->add_user_archive_items();
} elseif ( get_query_var( 'minute' ) && get_query_var( 'hour' ) ) {
$this->add_minute_hour_archive_items();
} elseif ( get_query_var( 'minute' ) ) {
$this->add_minute_archive_items();
} elseif ( get_query_var( 'hour' ) ) {
$this->add_hour_archive_items();
} elseif ( is_day() ) {
$this->add_day_archive_items();
} elseif ( get_query_var( 'w' ) ) {
$this->add_week_archive_items();
} elseif ( is_month() ) {
$this->add_month_archive_items();
} elseif ( is_year() ) {
$this->add_year_archive_items();
} else {
$this->add_default_archive_items();
}
} elseif ( is_search() ) {
$this->add_search_items();
} elseif ( is_404() ) {
$this->add_404_items();
}
}
// Add paged items if they exist.
$this->add_paged_items();
// Allow developers to overwrite the items for the breadcrumb trail.
$this->items = array_unique( apply_filters( 'sinatra_breadcrumb_trail_items', $this->items, $this->args ) );
}
/**
* Gets front items based on $wp_rewrite->front.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_rewrite_front_items() {
global $wp_rewrite;
if ( $wp_rewrite->front ) {
$this->add_path_parents( $wp_rewrite->front );
}
}
/**
* Adds the page/paged number to the items array.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_paged_items() {
if ( is_singular() && 1 < get_query_var( 'page' ) && true === $this->args['show_title'] ) {
// If viewing a paged singular post.
$this->items[] = sprintf( $this->labels['paged'], number_format_i18n( absint( get_query_var( 'page' ) ) ) );
} elseif ( is_singular() && get_option( 'page_comments' ) && 1 < get_query_var( 'cpage' ) ) {
// If viewing a singular post with paged comments.
$this->items[] = sprintf( $this->labels['paged_comments'], number_format_i18n( absint( get_query_var( 'cpage' ) ) ) );
} elseif ( is_paged() && true === $this->args['show_title'] ) {
// If viewing a paged archive-type page.
$this->items[] = sprintf( $this->labels['paged'], number_format_i18n( absint( get_query_var( 'paged' ) ) ) );
}
}
/**
* Adds the network (all sites) home page link to the items array.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_network_home_link() {
if ( is_multisite() && ! is_main_site() && true === $this->args['network'] ) {
$this->items[] = sprintf( '%s', esc_url( network_home_url() ), $this->labels['home'] );
}
}
/**
* Adds the current site's home page link to the items array.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_site_home_link() {
$network = is_multisite() && ! is_main_site() && true === $this->args['network'];
$label = $network ? get_bloginfo( 'name' ) : $this->labels['home'];
$rel = $network ? '' : ' rel="home"';
$this->items[] = sprintf( '%s', esc_url( user_trailingslashit( home_url() ) ), $rel, $label );
}
/**
* Adds items for the front page to the items array.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_front_page_items() {
// Only show front items if the 'show_on_front' argument is set to 'true'.
if ( true === $this->args['show_on_front'] || is_paged() || ( is_singular() && 1 < get_query_var( 'page' ) ) ) {
// Add network home link.
$this->add_network_home_link();
if ( is_paged() ) {
// If on a paged view, add the site home link.
$this->add_site_home_link();
} elseif ( true === $this->args['show_title'] ) {
// If on the main front page, add the network home title.
$this->items[] = is_multisite() && true === $this->args['network'] ? get_bloginfo( 'name' ) : $this->labels['home'];
}
}
}
/**
* Adds items for the posts page (i.e., is_home()) to the items array.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_blog_items() {
// Get the post ID and post.
$post_id = get_queried_object_id();
$post = get_post( $post_id );
// If the post has parents, add them to the trail.
if ( 0 < $post->post_parent ) {
$this->add_post_parents( $post->post_parent );
}
// Get the page title.
$title = get_the_title( $post_id );
// Add the posts page item.
if ( is_paged() ) {
$this->items[] = sprintf( '%s', esc_url( get_permalink( $post_id ) ), $title );
} elseif ( $title && true === $this->args['show_title'] ) {
$this->items[] = $title;
}
}
/**
* Adds singular post items to the items array.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_singular_items() {
// Get the queried post.
$post = get_queried_object();
$post_id = get_queried_object_id();
if ( 0 < $post->post_parent ) {
// If the post has a parent, follow the parent trail.
$this->add_post_parents( $post->post_parent );
} else {
// If the post doesn't have a parent, get its hierarchy based off the post type.
$this->add_post_hierarchy( $post_id );
}
// Display terms for specific post type taxonomy if requested.
if ( ! empty( $this->post_taxonomy[ $post->post_type ] ) ) {
$this->add_post_terms( $post_id, $this->post_taxonomy[ $post->post_type ] );
}
// End with the post title.
$post_title = single_post_title( '', false );
if ( $post_title ) {
if ( ( 1 < get_query_var( 'page' ) || is_paged() ) || ( get_option( 'page_comments' ) && 1 < absint( get_query_var( 'cpage' ) ) ) ) {
$this->items[] = sprintf( '%s', esc_url( get_permalink( $post_id ) ), $post_title );
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = $post_title;
}
}
}
/**
* Adds the items to the trail items array for taxonomy term archives.
*
* @since 1.0.0
* @access protected
* @global object $wp_rewrite
* @return void
*/
protected function add_term_archive_items() {
global $wp_rewrite;
// Get some taxonomy and term variables.
$term = get_queried_object();
$taxonomy = get_taxonomy( $term->taxonomy );
$done_post_type = false;
// If there are rewrite rules for the taxonomy.
if ( false !== $taxonomy->rewrite ) {
// If 'with_front' is true, dd $wp_rewrite->front to the trail.
if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front ) {
$this->add_rewrite_front_items();
}
// Get parent pages by path if they exist.
$this->add_path_parents( $taxonomy->rewrite['slug'] );
// Add post type archive if its 'has_archive' matches the taxonomy rewrite 'slug'.
if ( $taxonomy->rewrite['slug'] ) {
$slug = trim( $taxonomy->rewrite['slug'], '/' );
// Deals with the situation if the slug has a '/' between multiple
// strings. For example, "movies/genres" where "movies" is the post
// type archive.
$matches = explode( '/', $slug );
// If matches are found for the path.
if ( isset( $matches ) ) {
// Reverse the array of matches to search for posts in the proper order.
$matches = array_reverse( $matches );
// Loop through each of the path matches.
foreach ( $matches as $match ) {
// Get public post types that match the rewrite slug.
$post_types = $this->get_post_types_by_slug( $match );
if ( ! empty( $post_types ) ) {
$post_type_object = $post_types[0];
// Add support for a non-standard label of 'archive_title' (special use case).
$label = ! empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
// Core filter hook.
$label = apply_filters( 'sinatra_post_type_archive_title', $label, $post_type_object->name );
// Add the post type archive link to the trail.
$this->items[] = sprintf( '%s', esc_url( get_post_type_archive_link( $post_type_object->name ) ), $label );
$done_post_type = true;
// Break out of the loop.
break;
}
}
}
}
}
// If there's a single post type for the taxonomy, use it.
if ( false === $done_post_type && 1 === count( $taxonomy->object_type ) && post_type_exists( $taxonomy->object_type[0] ) ) {
// If the post type is 'post'.
if ( 'post' === $taxonomy->object_type[0] ) {
$post_id = get_option( 'page_for_posts' );
if ( 'posts' !== get_option( 'show_on_front' ) && 0 < $post_id ) {
$this->items[] = sprintf( '%s', esc_url( get_permalink( $post_id ) ), get_the_title( $post_id ) );
}
// If the post type is not 'post'.
} else {
$post_type_object = get_post_type_object( $taxonomy->object_type[0] );
$label = ! empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
// Core filter hook.
$label = apply_filters( 'sinatra_post_type_archive_title', $label, $post_type_object->name );
$this->items[] = sprintf( '%s', esc_url( get_post_type_archive_link( $post_type_object->name ) ), $label );
}
}
// If the taxonomy is hierarchical, list its parent terms.
if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent ) {
$this->add_term_parents( $term->parent, $term->taxonomy );
}
// Add the term name to the trail end.
if ( is_paged() ) {
$this->items[] = sprintf( '%s', esc_url( get_term_link( $term, $term->taxonomy ) ), single_term_title( '', false ) );
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = single_term_title( '', false );
}
}
/**
* Adds the items to the trail items array for post type archives.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_post_type_archive_items() {
// Get the post type object.
$post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
if ( false !== $post_type_object->rewrite ) {
// If 'with_front' is true, add $wp_rewrite->front to the trail.
if ( $post_type_object->rewrite['with_front'] ) {
$this->add_rewrite_front_items();
}
// If there's a rewrite slug, check for parents.
if ( ! empty( $post_type_object->rewrite['slug'] ) ) {
$this->add_path_parents( $post_type_object->rewrite['slug'] );
}
}
// Add the post type [plural] name to the trail end.
if ( is_paged() || is_author() ) {
$this->items[] = sprintf( '%s', esc_url( get_post_type_archive_link( $post_type_object->name ) ), post_type_archive_title( '', false ) );
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = post_type_archive_title( '', false );
}
// If viewing a post type archive by author.
if ( is_author() ) {
$this->add_user_archive_items();
}
}
/**
* Adds the items to the trail items array for user (author) archives.
*
* @since 1.0.0
* @access protected
* @global object $wp_rewrite
* @return void
*/
protected function add_user_archive_items() {
global $wp_rewrite;
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Get the user ID.
$user_id = get_query_var( 'author' );
// If $author_base exists, check for parent pages.
if ( ! empty( $wp_rewrite->author_base ) && ! is_post_type_archive() ) {
$this->add_path_parents( $wp_rewrite->author_base );
}
// Add the author's display name to the trail end.
if ( is_paged() ) {
$this->items[] = sprintf( '%s', esc_url( get_author_posts_url( $user_id ) ), get_the_author_meta( 'display_name', $user_id ) );
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = get_the_author_meta( 'display_name', $user_id );
}
}
/**
* Adds the items to the trail items array for minute + hour archives.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_minute_hour_archive_items() {
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Add the minute + hour item.
if ( true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['archive_minute_hour'], get_the_time( esc_html_x( 'g:i a', 'minute and hour archives time format', 'sinatra' ) ) );
}
}
/**
* Adds the items to the trail items array for minute archives.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_minute_archive_items() {
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Add the minute item.
if ( true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['archive_minute'], get_the_time( esc_html_x( 'i', 'minute archives time format', 'sinatra' ) ) );
}
}
/**
* Adds the items to the trail items array for hour archives.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_hour_archive_items() {
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Add the hour item.
if ( true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['archive_hour'], get_the_time( esc_html_x( 'g a', 'hour archives time format', 'sinatra' ) ) );
}
}
/**
* Adds the items to the trail items array for day archives.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_day_archive_items() {
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Get year, month, and day.
$year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sinatra' ) ) );
$month = sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sinatra' ) ) );
$day = sprintf( $this->labels['archive_day'], get_the_time( esc_html_x( 'j', 'daily archives date format', 'sinatra' ) ) );
// Add the year and month items.
$this->items[] = sprintf( '%s', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
$this->items[] = sprintf( '%s', esc_url( get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ), $month );
// Add the day item.
if ( is_paged() ) {
$this->items[] = sprintf( '%s', esc_url( get_day_link( get_the_time( 'Y' ) ), get_the_time( 'm' ), get_the_time( 'd' ) ), $day );
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = $day;
}
}
/**
* Adds the items to the trail items array for week archives.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_week_archive_items() {
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Get the year and week.
$year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sinatra' ) ) );
$week = sprintf( $this->labels['archive_week'], get_the_time( esc_html_x( 'W', 'weekly archives date format', 'sinatra' ) ) );
// Add the year item.
$this->items[] = sprintf( '%s', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
// Add the week item.
if ( is_paged() ) {
$this->items[] = esc_url(
get_archives_link(
add_query_arg(
array(
'm' => get_the_time( 'Y' ),
'w' => get_the_time( 'W' ),
),
home_url()
),
$week,
false
)
);
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = $week;
}
}
/**
* Adds the items to the trail items array for month archives.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_month_archive_items() {
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Get the year and month.
$year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sinatra' ) ) );
$month = sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sinatra' ) ) );
// Add the year item.
$this->items[] = sprintf( '%s', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
// Add the month item.
if ( is_paged() ) {
$this->items[] = sprintf( '%s', esc_url( get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ), $month );
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = $month;
}
}
/**
* Adds the items to the trail items array for year archives.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_year_archive_items() {
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Get the year.
$year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sinatra' ) ) );
// Add the year item.
if ( is_paged() ) {
$this->items[] = sprintf( '%s', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = $year;
}
}
/**
* Adds the items to the trail items array for archives that don't have a more specific method
* defined in this class.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_default_archive_items() {
// If this is a date-/time-based archive, add $wp_rewrite->front to the trail.
if ( is_date() || is_time() ) {
$this->add_rewrite_front_items();
}
if ( true === $this->args['show_title'] ) {
$this->items[] = $this->labels['archives'];
}
}
/**
* Adds the items to the trail items array for search results.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_search_items() {
if ( is_paged() ) {
$this->items[] = sprintf( '%s', esc_url( get_search_link() ), sprintf( $this->labels['search'], get_search_query() ) );
} elseif ( true === $this->args['show_title'] ) {
$this->items[] = sprintf( $this->labels['search'], get_search_query() );
}
}
/**
* Adds the items to the trail items array for 404 pages.
*
* @since 1.0.0
* @access protected
* @return void
*/
protected function add_404_items() {
if ( true === $this->args['show_title'] ) {
$this->items[] = $this->labels['error_404'];
}
}
/**
* Adds a specific post's parents to the items array.
*
* @since 1.0.0
* @access protected
* @param int $post_id Post ID.
* @return void
*/
protected function add_post_parents( $post_id ) {
$parents = array();
while ( $post_id ) {
// Get the post by ID.
$post = get_post( $post_id );
// If we hit a page that's set as the front page, bail.
if ( 'page' === $post->post_type && 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) === $post_id ) {
break;
}
// Add the formatted post link to the array of parents.
$parents[] = sprintf( '%s', esc_url( get_permalink( $post_id ) ), get_the_title( $post_id ) );
// If there's no longer a post parent, break out of the loop.
if ( 0 >= $post->post_parent ) {
break;
}
// Change the post ID to the parent post to continue looping.
$post_id = $post->post_parent;
}
// Get the post hierarchy based off the final parent post.
$this->add_post_hierarchy( $post_id );
// Display terms for specific post type taxonomy if requested.
if ( ! empty( $this->post_taxonomy[ $post->post_type ] ) ) {
$this->add_post_terms( $post_id, $this->post_taxonomy[ $post->post_type ] );
}
// Merge the parent items into the items array.
$this->items = array_merge( $this->items, array_reverse( $parents ) );
}
/**
* Adds a specific post's hierarchy to the items array. The hierarchy is determined by post type's
* rewrite arguments and whether it has an archive page.
*
* @since 1.0.0
* @access protected
* @param int $post_id Post ID.
* @return void
*/
protected function add_post_hierarchy( $post_id ) {
// Get the post type.
$post_type = get_post_type( $post_id );
$post_type_object = get_post_type_object( $post_type );
if ( 'post' === $post_type ) {
// If this is the 'post' post type, get the rewrite front items and map the rewrite tags.
// Add $wp_rewrite->front to the trail.
$this->add_rewrite_front_items();
// Map the rewrite tags.
$this->map_rewrite_tags( $post_id, get_option( 'permalink_structure' ) );
} elseif ( false !== $post_type_object->rewrite ) {
// If the post type has rewrite rules.
// If 'with_front' is true, add $wp_rewrite->front to the trail.
if ( $post_type_object->rewrite['with_front'] ) {
$this->add_rewrite_front_items();
}
// If there's a path, check for parents.
if ( ! empty( $post_type_object->rewrite['slug'] ) ) {
$this->add_path_parents( $post_type_object->rewrite['slug'] );
}
}
// If there's an archive page, add it to the trail.
if ( $post_type_object->has_archive ) {
// Add support for a non-standard label of 'archive_title' (special use case).
$label = ! empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
// Core filter hook.
$label = apply_filters( 'sinatra_post_type_archive_title', $label, $post_type_object->name );
$this->items[] = sprintf( '%s', esc_url( get_post_type_archive_link( $post_type ) ), $label );
}
// Map the rewrite tags if there's a `%` in the slug.
if ( 'post' !== $post_type && ! empty( $post_type_object->rewrite['slug'] ) && false !== strpos( $post_type_object->rewrite['slug'], '%' ) ) {
$this->map_rewrite_tags( $post_id, $post_type_object->rewrite['slug'] );
}
}
/**
* Gets post types by slug. This is needed because the get_post_types() function doesn't exactly
* match the 'has_archive' argument when it's set as a string instead of a boolean.
*
* @since 0.6.0
* @access protected
* @param int $slug The post type archive slug to search for.
* @return array
*/
protected function get_post_types_by_slug( $slug ) {
$return = array();
$post_types = get_post_types( array(), 'objects' );
foreach ( $post_types as $type ) {
if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) ) {
$return[] = $type;
}
}
return $return;
}
/**
* Adds a post's terms from a specific taxonomy to the items array.
*
* @since 1.0.0
* @access protected
* @param int $post_id The ID of the post to get the terms for.
* @param string $taxonomy The taxonomy to get the terms from.
* @return void
*/
protected function add_post_terms( $post_id, $taxonomy ) {
// Get the post categories.
$terms = get_the_terms( $post_id, $taxonomy );
// Check that categories were returned.
if ( $terms && ! is_wp_error( $terms ) ) {
// Sort the terms by ID and get the first category.
if ( function_exists( 'wp_list_sort' ) ) {
$terms = wp_list_sort( $terms, 'term_id' );
} else {
usort( $terms, '_usort_terms_by_ID' );
}
$term = get_term( $terms[0], $taxonomy );
// If the category has a parent, add the hierarchy to the trail.
if ( 0 < $term->parent ) {
$this->add_term_parents( $term->parent, $taxonomy );
}
// Add the category archive link to the trail.
$this->items[] = sprintf( '%s', esc_url( get_term_link( $term, $taxonomy ) ), $term->name );
}
}
/**
* Get parent posts by path. Currently, this method only supports getting parents of the 'page'
* post type. The goal of this function is to create a clear path back to home given what would
* normally be a "ghost" directory. If any page matches the given path, it'll be added.
*
* @since 1.0.0
* @access protected
* @param string $path The path (slug) to search for posts by.
* @return void
*/
protected function add_path_parents( $path ) {
// Trim '/' off $path in case we just got a simple '/' instead of a real path.
$path = trim( $path, '/' );
// If there's no path, return.
if ( empty( $path ) ) {
return;
}
// Get parent post by the path.
$post = get_page_by_path( $path );
if ( ! empty( $post ) ) {
$this->add_post_parents( $post->ID );
} elseif ( is_null( $post ) ) {
// Separate post names into separate paths by '/'.
$path = trim( $path, '/' );
preg_match_all( '/\/.*?\z/', $path, $matches );
// If matches are found for the path.
if ( isset( $matches ) ) {
// Reverse the array of matches to search for posts in the proper order.
$matches = array_reverse( $matches );
// Loop through each of the path matches.
foreach ( $matches as $match ) {
// If a match is found.
if ( isset( $match[0] ) ) {
// Get the parent post by the given path.
$path = str_replace( $match[0], '', $path );
$post = get_page_by_path( trim( $path, '/' ) );
// If a parent post is found, set the $post_id and break out of the loop.
if ( ! empty( $post ) && 0 < $post->ID ) {
$this->add_post_parents( $post->ID );
break;
}
}
}
}
}
}
/**
* Searches for term parents of hierarchical taxonomies. This function is similar to the WordPress
* function get_category_parents() but handles any type of taxonomy.
*
* @since 1.0.0
* @param int $term_id ID of the term to get the parents of.
* @param string $taxonomy Name of the taxonomy for the given term.
* @return void
*/
protected function add_term_parents( $term_id, $taxonomy ) {
// Set up some default arrays.
$parents = array();
// While there is a parent ID, add the parent term link to the $parents array.
while ( $term_id ) {
// Get the parent term.
$term = get_term( $term_id, $taxonomy );
// Add the formatted term link to the array of parent terms.
$parents[] = sprintf( '%s', esc_url( get_term_link( $term, $taxonomy ) ), $term->name );
// Set the parent term's parent as the parent ID.
$term_id = $term->parent;
}
// If we have parent terms, reverse the array to put them in the proper order for the trail.
if ( ! empty( $parents ) ) {
$this->items = array_merge( $this->items, array_reverse( $parents ) );
}
}
/**
* Turns %tag% from permalink structures into usable links for the breadcrumb trail. This feels kind of
* hackish for now because we're checking for specific %tag% examples and only doing it for the 'post'
* post type. In the future, maybe it'll handle a wider variety of possibilities, especially for custom post
* types.
*
* @since 0.6.0
* @access protected
* @param int $post_id ID of the post whose parents we want.
* @param string $path Path of a potential parent page.
* @return void
*/
protected function map_rewrite_tags( $post_id, $path ) {
$post = get_post( $post_id );
// Trim '/' from both sides of the $path.
$path = trim( $path, '/' );
// Split the $path into an array of strings.
$matches = explode( '/', $path );
// If matches are found for the path.
if ( is_array( $matches ) ) {
// Loop through each of the matches, adding each to the $trail array.
foreach ( $matches as $match ) {
// Trim any '/' from the $match.
$tag = trim( $match, '/' );
if ( '%year%' === $tag ) {
// If using the %year% tag, add a link to the yearly archive.
$this->items[] = sprintf( '%s', esc_url( get_year_link( get_the_time( 'Y', $post_id ) ) ), sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'sinatra' ) ) ) );
} elseif ( '%monthnum%' === $tag ) {
// If using the %monthnum% tag, add a link to the monthly archive.
$this->items[] = sprintf( '%s', esc_url( get_month_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ) ) ), sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'sinatra' ) ) ) );
} elseif ( '%day%' === $tag ) {
// If using the %day% tag, add a link to the daily archive.
$this->items[] = sprintf( '%s', esc_url( get_day_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ), get_the_time( 'd', $post_id ) ) ), sprintf( $this->labels['archive_day'], get_the_time( esc_html_x( 'j', 'daily archives date format', 'sinatra' ) ) ) );
} elseif ( '%author%' === $tag ) {
// If using the %author% tag, add a link to the post author archive.
$this->items[] = sprintf( '%s', esc_url( get_author_posts_url( $post->post_author ) ), get_the_author_meta( 'display_name', $post->post_author ) );
} elseif ( taxonomy_exists( trim( $tag, '%' ) ) ) {
// If using the %category% tag, add a link to the first category archive to match permalinks.
// Force override terms in this post type.
$this->post_taxonomy[ $post->post_type ] = false;
// Add the post categories.
$this->add_post_terms( $post_id, trim( $tag, '%' ) );
}
}
}
}
}
class-sinatra-dynamic-styles.php 0000644 00000221052 15123153670 0012771 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Sinatra_Dynamic_Styles' ) ) :
/**
* Dynamically generate CSS code.
*/
class Sinatra_Dynamic_Styles {
/**
* Singleton instance of the class.
*
* @since 1.0.0
* @var object
*/
private static $instance;
/**
* URI for Dynamic CSS file.
*
* @since 1.0.0
* @var object
*/
private $dynamic_css_uri;
/**
* Path for Dynamic CSS file.
*
* @since 1.0.0
* @var object
*/
private $dynamic_css_path;
/**
* Main Sinatra_Dynamic_Styles Instance.
*
* @since 1.0.0
* @return Sinatra_Dynamic_Styles
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Sinatra_Dynamic_Styles ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Primary class constructor.
*
* @since 1.0.0
*/
public function __construct() {
$upload_dir = wp_upload_dir();
$this->dynamic_css_uri = trailingslashit( set_url_scheme( $upload_dir['baseurl'] ) ) . 'sinatra/';
$this->dynamic_css_path = trailingslashit( set_url_scheme( $upload_dir['basedir'] ) ) . 'sinatra/';
if ( ! is_customize_preview() && wp_is_writable( trailingslashit( $upload_dir['basedir'] ) ) ) {
add_action( 'sinatra_enqueue_scripts', array( $this, 'enqueue_dynamic_style' ), 20 );
} else {
add_action( 'sinatra_enqueue_scripts', array( $this, 'print_dynamic_style' ), 99 );
}
// Include button styles.
add_filter( 'sinatra_dynamic_styles', array( $this, 'get_button_styles' ), 6 );
// Remove Customizer Custom CSS from wp_head, we will include it in our dynamic file.
if ( ! is_customize_preview() ) {
remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
}
// Generate new styles on Customizer Save action.
add_action( 'customize_save_after', array( $this, 'update_dynamic_file' ) );
// Generate new styles on theme activation.
add_action( 'after_switch_theme', array( $this, 'update_dynamic_file' ) );
// Delete the css stye on theme deactivation.
add_action( 'switch_theme', array( $this, 'delete_dynamic_file' ) );
// Generate initial dynamic css.
add_action( 'init', array( $this, 'init' ) );
}
/**
* Init.
*
* @since 1.0.0
*/
public function init() {
// Ensure we have dynamic stylesheet generated.
if ( false === get_transient( 'sinatra_has_dynamic_css' ) ) {
$this->update_dynamic_file();
}
}
/**
* Enqueues dynamic styles file.
*
* @since 1.0.0
*/
public function enqueue_dynamic_style() {
$exists = file_exists( $this->dynamic_css_path . 'dynamic-styles.css' );
// Generate the file if it's missing.
if ( ! $exists ) {
$exists = $this->update_dynamic_file();
}
// Enqueue the file if available.
if ( $exists ) {
wp_enqueue_style(
'sinatra-dynamic-styles',
$this->dynamic_css_uri . 'dynamic-styles.css',
false,
filemtime( $this->dynamic_css_path . 'dynamic-styles.css' ),
'all'
);
}
}
/**
* Prints inline dynamic styles if writing to file is not possible.
*
* @since 1.0.0
*/
public function print_dynamic_style() {
$dynamic_css = $this->get_css();
wp_add_inline_style( 'sinatra-styles', $dynamic_css );
}
/**
* Generates dynamic CSS code, minifies it and cleans cache.
*
* @param boolean $custom_css - should we include the wp_get_custom_css.
* @return string, minifed code
* @since 1.0.0
*/
public function get_css( $custom_css = false ) {
// Refresh options.
sinatra()->options->refresh();
// Delete google fonts enqueue transients.
delete_transient( 'sinatra_google_fonts_enqueue' );
// Add our theme custom CSS.
$css = '';
// Accent color.
$accent_color = sinatra_option( 'accent_color' );
$css .= '
#si-scroll-top:hover::before,
.si-btn,
input[type=submit],
input[type=reset],
.comment-form input[type=checkbox]:checked,
#comments .bypostauthor-badge,
.single .post-tags a:hover,
.single .post-category .cat-links a:hover,
.tagcloud a:hover,
#main .mejs-controls .mejs-time-rail .mejs-time-current,
.si-btn.sinatra-read-more::after,
.post_format-post-format-quote .si-blog-entry-content .quote-post-bg::after,
.si-hover-slider .post-category a,
.si-single-title-in-page-header.single .page-header .post-category a,
.entry-media > a:hover .entry-media-icon::before,
.si-pre-footer-cta-style-1 #si-pre-footer .si-flex-row::after,
.si-pre-footer-cta-style-2 #si-pre-footer::after,
.select2-container--default .select2-results__option--highlighted[aria-selected],
.si-input-supported input[type=radio]:checked::before,
.si-input-supported input[type=checkbox]:checked,
.sinatra-sidebar-style-2 #secondary .widget-title::before,
.sinatra-sidebar-style-2 .elementor-widget-sidebar .widget-title::before,
.widget .cat-item a:hover + span,
.widget_archive li a:hover + span,
.widget .cat-item.current-cat a + span,
#sinatra-footer .widget .cat-item a:hover + span,
#sinatra-footer .widget_archive li a:hover + span,
#sinatra-footer .widget .cat-item.current-cat a + span,
.si-btn.btn-outline:hover,
#infinite-handle span {
background-color: ' . $accent_color . ';
}
.si-btn:hover,
#infinite-handle span:hover,
input[type=submit]:hover,
input[type=reset]:hover,
input[type=reset]:focus,
.si-btn:focus,
input[type=submit]:focus,
.si-hover-slider .post-category a:hover,
.si-single-title-in-page-header.single .page-header .post-category a:hover {
background-color: ' . sinatra_luminance( $accent_color, .15 ) . ';
}
mark,
span.highlight,
code,
kbd,
var,
samp,
tt {
background-color: ' . sinatra_hex2rgba( $accent_color, .09 ) . ';
}
code.block {
background-color: ' . sinatra_hex2rgba( $accent_color, .075 ) . ';
}
.content-area a:not(.si-btn):not(.wp-block-button__link),
#secondary .sinatra-core-custom-list-widget .si-entry a:not(.si-btn),
#secondary a:not(.si-btn):hover,
.si-header-widgets .si-header-widget.sinatra-active .si-icon.si-search,
.sinatra-logo .site-title a:hover,
#sinatra-header-inner .sinatra-nav > ul > li > a:hover,
#sinatra-header-inner .sinatra-nav > ul > li.menu-item-has-children:hover > a,
#sinatra-header-inner .sinatra-nav > ul > li.current-menu-item > a,
#sinatra-header-inner .sinatra-nav > ul > li.current-menu-ancestor > a,
#sinatra-header-inner .sinatra-nav > ul > li.page_item_has_children:hover > a,
#sinatra-header-inner .sinatra-nav > ul > li.current_page_item > a,
#sinatra-header-inner .sinatra-nav > ul > li.current_page_ancestor > a,
#sinatra-topbar .sinatra-nav > ul > li > a:hover,
#sinatra-topbar .sinatra-nav > ul > li.menu-item-has-children:hover > a,
#sinatra-topbar .sinatra-nav > ul > li.current-menu-item > a,
#sinatra-topbar .sinatra-nav > ul > li.current-menu-ancestor > a,
.si-topbar-widget__text a:hover,
.si-topbar-widget__text a,
.sinatra-social-nav > ul > li > a .si-icon.bottom-icon,
.si-header-widgets a:not(.si-btn):hover,
#sinatra-header-inner .si-header-widgets .sinatra-active,
.sinatra-pagination .navigation .nav-links .page-numbers:hover,
.widget .cat-item.current-cat > a,
.widget ul li.current_page_item > a,
#main .search-form .search-submit:hover,
#colophon .search-form .search-submit:hover,
#cancel-comment-reply-link:hover,
.comment-form .required,
.navigation .nav-links .page-numbers:hover,
#main .entry-meta a:hover,
#main .author-box-title a:hover,
.single .post-category a,
.page-links span:hover,
.site-content .page-links span:hover,
.navigation .nav-links .page-numbers.current,
.page-links > span,
.site-content .page-links > span,
.si-btn.btn-outline,
code,
kbd,
var,
samp,
tt,
.is-mobile-menu-active .si-hamburger,
.si-hamburger:hover,
.single #main .post-nav a:hover,
#sinatra-topbar .si-topbar-widget__text .si-icon {
color: ' . $accent_color . ';
}
#page ::-moz-selection { background-color: ' . $accent_color . '; color: #FFF; }
#page ::selection { background-color: ' . $accent_color . '; color: #FFF; }
#comments .comment-actions .reply a:hover,
.comment-form input[type=checkbox]:checked,
.comment-form input[type=checkbox]:focus,
.comment-form input[type=radio]:checked,
.comment-form input[type=radio]:focus,
.single .post-category a,
#colophon,
#secondary .widget-title,
.elementor-widget-sidebar .widget-title,
.si-hover-slider .post-category a,
.si-single-title-in-page-header.single .page-header .post-category a,
.si-entry blockquote,
.wp-block-quote.is-style-large,
.wp-block-quote.is-large,
.wp-block-quote.has-text-align-right,
.navigation .nav-links .page-numbers.current,
.page-links > span,
.site-content .page-links > span,
.si-input-supported input[type=radio]:checked,
.si-input-supported input[type=checkbox]:checked,
.si-btn.btn-outline {
border-color: ' . $accent_color . ';
}
#masthead .si-header-widgets .dropdown-item::after,
.sinatra-nav > ul .sub-menu::after,
textarea:focus, input[type="text"]:focus,
input[type="email"]:focus,
input[type=password]:focus,
input[type=tel]:focus,
input[type=url]:focus,
input[type=search]:focus,
input[type=date]:focus {
border-bottom-color: ' . $accent_color . ';
outline: none !important;
}
.si-header-widgets .dropdown-item,
.preloader-1 > div,
.sinatra-nav .sub-menu {
border-top-color: ' . $accent_color . ';
}
.sinatra-animate-arrow:hover .arrow-handle,
.sinatra-animate-arrow:hover .arrow-bar,
.sinatra-animate-arrow:focus .arrow-handle,
.sinatra-animate-arrow:focus .arrow-bar,
.sinatra-pagination .navigation .nav-links .page-numbers.next:hover .sinatra-animate-arrow .arrow-handle,
.sinatra-pagination .navigation .nav-links .page-numbers.prev:hover .sinatra-animate-arrow .arrow-handle,
.sinatra-pagination .navigation .nav-links .page-numbers.next:hover .sinatra-animate-arrow .arrow-bar,
.sinatra-pagination .navigation .nav-links .page-numbers.prev:hover .sinatra-animate-arrow .arrow-bar {
fill: ' . $accent_color . ';
}
.si-input-supported input[type=checkbox]:focus:hover {
box-shadow: inset 0 0 0 2px ' . $accent_color . ';
}
';
$header_layout_3_additional_css = '';
if ( 'layout-3' === sinatra_option( 'header_layout' ) || is_customize_preview() ) {
$header_layout_3_additional_css = '
.sinatra-header-layout-3 .si-logo-container > .si-container {
flex-wrap: wrap;
}
.sinatra-header-layout-3 .si-logo-container .sinatra-logo > .logo-inner {
align-items: flex-start;
}
.sinatra-header-layout-3 .si-logo-container .sinatra-logo {
order: 0;
align-items: flex-start;
flex-basis: auto;
margin-left: 0;
}
.sinatra-header-layout-3 .si-logo-container .si-header-element {
flex-basis: auto;
}
.sinatra-header-layout-3 .si-logo-container .si-mobile-nav {
order: 5;
}
';
}
/**
* Top Bar.
*/
// Background.
$css .= $this->get_design_options_field_css( '#sinatra-topbar', 'top_bar_background', 'background' );
// Border.
$css .= $this->get_design_options_field_css( '#sinatra-topbar', 'top_bar_border', 'border' );
$css .= $this->get_design_options_field_css( '.si-topbar-widget', 'top_bar_border', 'separator_color' );
// Top Bar colors.
$topbar_color = sinatra_option( 'top_bar_text_color' );
// Top Bar text color.
if ( isset( $topbar_color['text-color'] ) && $topbar_color['text-color'] ) {
$css .= '#sinatra-topbar { color: ' . $topbar_color['text-color'] . '; }';
}
// Top Bar link color.
if ( isset( $topbar_color['link-color'] ) && $topbar_color['link-color'] ) {
$css .= '
.si-topbar-widget__text a,
.si-topbar-widget .sinatra-nav > ul > li > a,
.si-topbar-widget__socials .sinatra-social-nav > ul > li > a,
#sinatra-topbar .si-topbar-widget__text .si-icon {
color: ' . $topbar_color['link-color'] . '; }
';
}
// Top Bar link hover color.
if ( isset( $topbar_color['link-hover-color'] ) && $topbar_color['link-hover-color'] ) {
$css .= '
#sinatra-topbar .sinatra-nav > ul > li > a:hover,
#sinatra-topbar .sinatra-nav > ul > li.menu-item-has-children:hover > a,
#sinatra-topbar .sinatra-nav > ul > li.current-menu-item > a,
#sinatra-topbar .sinatra-nav > ul > li.current-menu-ancestor > a,
#sinatra-topbar .si-topbar-widget__text a:hover,
#sinatra-topbar .sinatra-social-nav > ul > li > a .si-icon.bottom-icon {
color: ' . $topbar_color['link-hover-color'] . '; }
';
}
/**
* Header.
*/
// Background.
$css .= $this->get_design_options_field_css( '#sinatra-header-inner', 'header_background', 'background' );
// Font colors.
$header_color = sinatra_option( 'header_text_color' );
// Header text color.
if ( isset( $header_color['text-color'] ) && $header_color['text-color'] ) {
$css .= '.sinatra-logo .site-description { color: ' . $header_color['text-color'] . '; }';
}
// Header link color.
if ( isset( $header_color['link-color'] ) && $header_color['link-color'] ) {
$css .= '
#sinatra-header,
.si-header-widgets a:not(.si-btn),
.sinatra-logo a,
.si-hamburger {
color: ' . $header_color['link-color'] . '; }
';
}
// Header link hover color.
if ( isset( $header_color['link-hover-color'] ) && $header_color['link-hover-color'] ) {
$css .= '
.si-header-widgets a:not(.si-btn):hover,
#sinatra-header-inner .si-header-widgets .sinatra-active,
.sinatra-logo .site-title a:hover,
.si-hamburger:hover,
.is-mobile-menu-active .si-hamburger,
#sinatra-header-inner .sinatra-nav > ul > li > a:hover,
#sinatra-header-inner .sinatra-nav > ul > li.menu-item-has-children:hover > a,
#sinatra-header-inner .sinatra-nav > ul > li.current-menu-item > a,
#sinatra-header-inner .sinatra-nav > ul > li.current-menu-ancestor > a,
#sinatra-header-inner .sinatra-nav > ul > li.page_item_has_children:hover > a,
#sinatra-header-inner .sinatra-nav > ul > li.current_page_item > a,
#sinatra-header-inner .sinatra-nav > ul > li.current_page_ancestor > a {
color: ' . $header_color['link-hover-color'] . ';
}
';
}
// Header border.
$css .= $this->get_design_options_field_css( '#sinatra-header-inner', 'header_border', 'border' );
// Header separator color.
$css .= $this->get_design_options_field_css( '.si-header-widget', 'header_border', 'separator_color' );
// Main navigation breakpoint.
$css .= '
@media screen and (max-width: ' . intval( sinatra_option( 'main_nav_mobile_breakpoint' ) ) . 'px) {
#sinatra-header-inner .sinatra-nav {
display: none;
color: #000;
}
.si-mobile-nav {
display: inline-flex;
}
#sinatra-header-inner {
position: relative;
}
#sinatra-header-inner .sinatra-nav > ul > li > a {
color: inherit;
}
#sinatra-header-inner .si-nav-container {
position: static;
border: none;
}
#sinatra-header-inner .site-navigation {
display: none;
position: absolute;
top: 100%;
width: 100%;
left: 0;
right: 0;
margin: -1px 0 0;
background: #FFF;
border-top: 1px solid #eaeaea;
box-shadow: 0 15px 25px -10px rgba(50, 52, 54, 0.125);
z-index: 999;
font-size: 1rem;
padding: 0;
}
#sinatra-header-inner .site-navigation > ul {
max-height: initial;
display: block;
}
#sinatra-header-inner .site-navigation > ul > li > a {
padding: 0 !important;
}
#sinatra-header-inner .site-navigation > ul li {
display: block;
width: 100%;
padding: 0;
margin: 0;
margin-left: 0 !important;
}
#sinatra-header-inner .site-navigation > ul .sub-menu {
position: static;
display: none;
border: none;
box-shadow: none;
border: 0;
opacity: 1;
visibility: visible;
font-size: rem(14px);
transform: none;
background: #f8f8f8;
pointer-events: all;
min-width: initial;
left: 0;
padding: 0;
margin: 0;
border-radius: 0;
line-height: inherit;
}
#sinatra-header-inner .site-navigation > ul .sub-menu > li > a > span {
padding-left: 50px !important;
}
#sinatra-header-inner .site-navigation > ul .sub-menu .sub-menu > li > a > span {
padding-left: 70px !important;
}
#sinatra-header-inner .site-navigation > ul .sub-menu a > span {
padding: 10px 30px 10px 50px;
}
#sinatra-header-inner .site-navigation > ul a {
padding: 0;
position: relative;
border-bottom: 1px solid #eaeaea;
background: none;
}
#sinatra-header-inner .site-navigation > ul a > span {
padding: 10px 30px !important;
width: 100%;
display: block;
}
#sinatra-header-inner .site-navigation > ul a > span::after,
#sinatra-header-inner .site-navigation > ul a > span::before {
display: none !important;
}
#sinatra-header-inner .site-navigation > ul a > span.description {
display: none;
}
#sinatra-header-inner .site-navigation > ul .menu-item-has-children > a > span {
max-width: calc(100% - 50px);
}
#sinatra-header-inner .site-navigation > ul .menu-item-has-children > a::after {
font-family: "sinatra" !important;
content: "\e92e" !important;
position: absolute !important;
top: 0 !important;
bottom: 0;
right: 0;
border-left: 1px solid rgba(0,0,0,.09);
display: flex;
align-items: center;
justify-content: center;
width: 50px;
margin: 0 !important;
font-size: 1em;
transform: none !important;
}
#sinatra-header-inner .site-navigation > ul .menu-item-has-children.si-open > a::after {
content: "\e931" !important;
}
.sinatra-header-layout-3 .sinatra-widget-location-left .dropdown-item {
left: auto;
right: -7px;
}
.sinatra-header-layout-3 .sinatra-widget-location-left .dropdown-item::after {
left: auto;
right: 8px;
}
.sinatra-nav .sub-menu li.current-menu-item > a {
font-weight: bold;
}
' . $header_layout_3_additional_css . '
}
';
/**
* Main Navigation.
*/
// Font Color.
$main_nav_font_color = sinatra_option( 'main_nav_font_color' );
if ( $main_nav_font_color['link-color'] ) {
$css .= '#sinatra-header-inner .sinatra-nav > ul > li > a { color: ' . $main_nav_font_color['link-color'] . '; }';
}
if ( $main_nav_font_color['link-hover-color'] ) {
$css .= '
#sinatra-header-inner .sinatra-nav > ul > li > a:hover,
#sinatra-header-inner .sinatra-nav > ul > li.menu-item-has-children:hover > a,
#sinatra-header-inner .sinatra-nav > ul > li.current-menu-item > a,
#sinatra-header-inner .sinatra-nav > ul > li.current-menu-ancestor > a,
#sinatra-header-inner .sinatra-nav > ul > li.page_item_has_children:hover > a,
#sinatra-header-inner .sinatra-nav > ul > li.current_page_item > a,
#sinatra-header-inner .sinatra-nav > ul > li.current_page_ancestor > a {
color: ' . $main_nav_font_color['link-hover-color'] . ';
}
';
}
if ( 'layout-3' === sinatra_option( 'header_layout' ) ) {
// Background.
$css .= $this->get_design_options_field_css( '.sinatra-header-layout-3 .si-nav-container', 'main_nav_background', 'background' );
// Border.
$css .= $this->get_design_options_field_css( '.sinatra-header-layout-3 .si-nav-container', 'main_nav_border', 'border' );
}
// Font size.
$css .= $this->get_range_field_css( '.sinatra-nav.si-header-element, .sinatra-header-layout-1 .si-header-widgets, .sinatra-header-layout-2 .si-header-widgets', 'font-size', 'main_nav_font_size', false );
/**
* Hero Section.
*/
if ( sinatra_option( 'enable_hero' ) ) {
// Hero height.
$css .= '#hero .si-hover-slider .hover-slide-item { height: ' . sinatra_option( 'hero_hover_slider_height' ) . 'px; }';
}
/**
* Pre Footer.
*/
if ( sinatra_option( 'enable_pre_footer_cta' ) ) {
// Call to Action.
if ( sinatra_option( 'enable_pre_footer_cta' ) ) {
$cta_style = absint( sinatra_option( 'pre_footer_cta_style' ) );
// Background.
$cta_background = sinatra_option( 'pre_footer_cta_background' );
if ( 1 === $cta_style || is_customize_preview() ) {
$css .= $this->get_design_options_field_css( '.si-pre-footer-cta-style-1 #si-pre-footer .si-flex-row::after', 'pre_footer_cta_background', 'background' );
}
if ( 2 === $cta_style || is_customize_preview() ) {
$css .= $this->get_design_options_field_css( '.si-pre-footer-cta-style-2 #si-pre-footer::after', 'pre_footer_cta_background', 'background' );
}
if ( 'image' === $cta_background['background-type'] && isset( $cta_background['background-color-overlay'] ) && $cta_background['background-color-overlay'] ) {
$css .= '
.si-pre-footer-cta-style-1 #si-pre-footer .si-flex-row::before,
.si-pre-footer-cta-style-2 #si-pre-footer::before {
background-color: ' . $cta_background['background-color-overlay'] . ';
}
';
}
// Text color.
$css .= $this->get_design_options_field_css( '#si-pre-footer .h2, #si-pre-footer .h3, #si-pre-footer .h4', 'pre_footer_cta_text_color', 'color' );
// Border.
if ( 1 === $cta_style || is_customize_preview() ) {
$css .= $this->get_design_options_field_css( '.si-pre-footer-cta-style-1 #si-pre-footer .si-flex-row::before', 'pre_footer_cta_border', 'border' );
}
if ( 2 === $cta_style || is_customize_preview() ) {
$css .= $this->get_design_options_field_css( '.si-pre-footer-cta-style-2 #si-pre-footer::before', 'pre_footer_cta_border', 'border' );
}
// Font size.
$css .= $this->get_range_field_css( '#si-pre-footer .h3', 'font-size', 'pre_footer_cta_font_size', true );
}
}
// Footer Background.
if ( sinatra_option( 'enable_footer' ) || sinatra_option( 'enable_copyright' ) ) {
// Background.
$css .= $this->get_design_options_field_css( '#colophon', 'footer_background', 'background' );
// Footer font color.
$footer_font_color = sinatra_option( 'footer_text_color' );
// Footer text color.
if ( isset( $footer_font_color['text-color'] ) && $footer_font_color['text-color'] ) {
$css .= '
#colophon {
color: ' . $footer_font_color['text-color'] . ';
}
';
}
// Footer link color.
if ( isset( $footer_font_color['link-color'] ) && $footer_font_color['link-color'] ) {
$css .= '
#colophon a {
color: ' . $footer_font_color['link-color'] . ';
}
';
}
// Footer link hover color.
if ( isset( $footer_font_color['link-hover-color'] ) && $footer_font_color['link-hover-color'] ) {
$css .= '
#colophon a:hover,
#colophon li.current_page_item > a,
#colophon .sinatra-social-nav > ul > li > a .si-icon.bottom-icon {
color: ' . $footer_font_color['link-hover-color'] . ';
}
';
}
// Footer widget title.
if ( isset( $footer_font_color['widget-title-color'] ) && $footer_font_color['widget-title-color'] ) {
$css .= '
#colophon .widget-title {
color: ' . $footer_font_color['widget-title-color'] . ';
}
';
}
}
// Main Footer border.
if ( sinatra_option( 'enable_footer' ) ) {
// Border.
$footer_border = sinatra_option( 'footer_border' );
if ( $footer_border['border-top-width'] ) {
$css .= '
#colophon {
border-top-width: ' . $footer_border['border-top-width'] . 'px;
border-top-style: ' . $footer_border['border-style'] . ';
border-top-color: ' . $footer_border['border-color'] . ';
}
';
}
if ( $footer_border['border-bottom-width'] ) {
$css .= '
#colophon {
border-bottom-width: ' . $footer_border['border-bottom-width'] . 'px;
border-bottom-style: ' . $footer_border['border-style'] . ';
border-bottom-color: ' . $footer_border['border-color'] . ';
}
';
}
}
// Sidebar.
$css .= '
#secondary {
width: ' . intval( sinatra_option( 'sidebar_width' ) ) . '%;
}
body:not(.sinatra-no-sidebar) #primary {
max-width: ' . intval( 100 - intval( sinatra_option( 'sidebar_width' ) ) ) . '%;
}
';
// Content background.
$boxed_content_background_color = sinatra_option( 'boxed_content_background_color' );
// Boxed Separated Layout specific CSS.
$css .= '
.sinatra-layout__boxed-separated.author .author-box,
.sinatra-layout__boxed-separated #content,
.sinatra-layout__boxed-separated.sinatra-sidebar-style-3 #secondary .si-widget,
.sinatra-layout__boxed-separated.sinatra-sidebar-style-3 .elementor-widget-sidebar .si-widget,
.sinatra-layout__boxed-separated.blog .sinatra-article,
.sinatra-layout__boxed-separated.search-results .sinatra-article,
.sinatra-layout__boxed-separated.category .sinatra-article {
background-color: ' . $boxed_content_background_color . ';
}
@media screen and (max-width: 960px) {
.sinatra-layout__boxed-separated #page {
background-color: ' . $boxed_content_background_color . ';
}
}
';
$css .= '
.sinatra-layout__boxed #page {
background-color: ' . $boxed_content_background_color . ';
}
';
// Content text color.
$content_text_color = sinatra_option( 'content_text_color' );
$css .= '
body {
color: ' . $content_text_color . ';
}
.comment-form .comment-notes,
#comments .no-comments,
#page .wp-caption .wp-caption-text,
#comments .comment-meta,
.comments-closed,
.entry-meta,
.si-entry cite,
legend,
.si-page-header-description,
.page-links em,
.site-content .page-links em,
.single .entry-footer .last-updated,
.single .post-nav .post-nav-title,
#main .widget_recent_comments span,
#main .widget_recent_entries span,
#main .widget_calendar table > caption,
.post-thumb-caption,
.wp-block-image figcaption,
.wp-block-embed figcaption {
color: ' . sinatra_hex2rgba( $content_text_color, 0.73 ) . ';
}
.navigation .nav-links .page-numbers svg {
fill: ' . sinatra_hex2rgba( $content_text_color, 0.73 ) . ';
}
';
// Lightened or darkened background color for backgrounds, borders & inputs.
$background_color = sinatra_get_background_color();
$content_text_color_offset = sinatra_light_or_dark( $background_color, sinatra_luminance( $background_color, -0.045 ), sinatra_luminance( $background_color, 0.2 ) );
// Only add for dark background color.
if ( ! sinatra_is_light_color( $background_color ) ) {
$css .= '
#content textarea,
#content input[type="text"],
#content input[type="number"],
#content input[type="email"],
#content input[type=password],
#content input[type=tel],
#content input[type=url],
#content input[type=search],
#content input[type=date] {
background-color: ' . $background_color . ';
}
';
// Offset border color.
$css .= '
.sinatra-sidebar-style-3 #secondary .si-widget {
border-color: ' . $content_text_color_offset . ';
}
';
// Offset background color.
$css .= '
.entry-meta .entry-meta-elements > span:before {
background-color: ' . $content_text_color_offset . ';
}
';
}
// Content link hover color.
$css .= '
.content-area a:not(.si-btn):not(.wp-block-button__link):hover,
#secondary .sinatra-core-custom-list-widget .si-entry a:not(.si-btn):hover,
.si-breadcrumbs a:hover {
color: ' . sinatra_option( 'content_link_hover_color' ) . ';
}
';
// Headings Color.
$css .= '
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3,
.sinatra-logo .site-title,
.error-404 .page-header h1 {
color: ' . sinatra_option( 'headings_color' ) . ';
}
';
// Container width.
$css .= '
.si-container,
.alignfull.si-wrap-content > div {
max-width: ' . sinatra_option( 'container_width' ) . 'px;
}
.sinatra-layout__boxed #page,
.sinatra-layout__boxed.si-sticky-header.sinatra-is-mobile #sinatra-header-inner,
.sinatra-layout__boxed.si-sticky-header:not(.sinatra-header-layout-3) #sinatra-header-inner,
.sinatra-layout__boxed.si-sticky-header:not(.sinatra-is-mobile).sinatra-header-layout-3 #sinatra-header-inner .si-nav-container > .si-container {
max-width: ' . ( intval( sinatra_option( 'container_width' ) ) + 100 ) . 'px;
}
';
// Adjust fullwidth sections for boxed layouts.
if ( 'boxed' === sinatra_option( 'site_layout' ) || is_customize_preview() ) {
$css .= '
@media screen and (max-width: ' . intval( sinatra_option( 'container_width' ) ) . 'px) {
body.sinatra-layout__boxed.sinatra-no-sidebar .elementor-section.elementor-section-stretched,
body.sinatra-layout__boxed.sinatra-no-sidebar .si-fw-section,
body.sinatra-layout__boxed.sinatra-no-sidebar .entry-content .alignfull {
margin-left: -50px !important;
margin-right: -50px !important;
}
}
';
}
// Logo max height.
$css .= $this->get_range_field_css( '.sinatra-logo img', 'max-height', 'logo_max_height' );
$css .= $this->get_range_field_css( '.sinatra-logo img.si-svg-logo', 'height', 'logo_max_height' );
// Logo margin.
$css .= $this->get_spacing_field_css( '.sinatra-logo .logo-inner', 'margin', 'logo_margin' );
/**
* Transparent header.
*/
// Logo max height.
$css .= $this->get_range_field_css( '.si-tsp-header .sinatra-logo img', 'max-height', 'tsp_logo_max_height' );
$css .= $this->get_range_field_css( '.si-tsp-header .sinatra-logo img.si-svg-logo', 'height', 'tsp_logo_max_height' );
// Logo margin.
$css .= $this->get_spacing_field_css( '.si-tsp-header .sinatra-logo .logo-inner', 'margin', 'tsp_logo_margin' );
// Main Header custom background.
$css .= $this->get_design_options_field_css( '.si-tsp-header #sinatra-header-inner', 'tsp_header_background', 'background' );
/** Font Colors */
$tsp_font_color = sinatra_option( 'tsp_header_font_color' );
// Header text color.
if ( isset( $tsp_font_color['text-color'] ) && $tsp_font_color['text-color'] ) {
$css .= '
.si-tsp-header .sinatra-logo .site-description {
color: ' . $tsp_font_color['text-color'] . ';
}
';
}
// Header link color.
if ( isset( $tsp_font_color['link-color'] ) && $tsp_font_color['link-color'] ) {
$css .= '
.si-tsp-header #sinatra-header,
.si-tsp-header .si-header-widgets a:not(.si-btn),
.si-tsp-header .sinatra-logo a,
.si-tsp-header .si-hamburger,
.si-tsp-header #sinatra-header-inner .sinatra-nav > ul > li > a {
color: ' . $tsp_font_color['link-color'] . ';
}
';
}
// Header link hover color.
if ( isset( $tsp_font_color['link-hover-color'] ) && $tsp_font_color['link-hover-color'] ) {
$css .= '
.si-tsp-header .si-header-widgets a:not(.si-btn):hover,
.si-tsp-header #sinatra-header-inner .si-header-widgets .sinatra-active,
.si-tsp-header .sinatra-logo .site-title a:hover,
.si-tsp-header .si-hamburger:hover,
.is-mobile-menu-active .si-tsp-header .si-hamburger,
.si-tsp-header #sinatra-header-inner .sinatra-nav > ul > li > a:hover,
.si-tsp-header #sinatra-header-inner .sinatra-nav > ul > li.menu-item-has-children:hover > a,
.si-tsp-header #sinatra-header-inner .sinatra-nav > ul > li.current-menu-item > a,
.si-tsp-header #sinatra-header-inner .sinatra-nav > ul > li.current-menu-ancestor > a,
.si-tsp-header #sinatra-header-inner .sinatra-nav > ul > li.page_item_has_children:hover > a,
.si-tsp-header #sinatra-header-inner .sinatra-nav > ul > li.current_page_item > a,
.si-tsp-header #sinatra-header-inner .sinatra-nav > ul > li.current_page_ancestor > a {
color: ' . $tsp_font_color['link-hover-color'] . ';
}
';
}
/** Border Color */
$css .= $this->get_design_options_field_css( '.si-tsp-header #sinatra-header-inner', 'tsp_header_border', 'border' );
/** Separator Color */
$css .= $this->get_design_options_field_css( '.si-tsp-header .si-header-widget', 'tsp_header_border', 'separator_color' );
/**
* Page Header.
*/
if ( sinatra_option( 'page_header_enable' ) ) {
// Font size.
$css .= $this->get_range_field_css( '#page .page-header .page-title', 'font-size', 'page_header_font_size', true );
// Page Title spacing.
$css .= $this->get_spacing_field_css( '.si-page-title-align-left .page-header.si-has-page-title, .si-page-title-align-right .page-header.si-has-page-title, .si-page-title-align-center .page-header .si-page-header-wrapper', 'padding', 'page_header_spacing' );
// Page Header background.
$css .= $this->get_design_options_field_css( '.si-tsp-header:not(.si-tsp-absolute) #masthead', 'page_header_background', 'background' );
$css .= $this->get_design_options_field_css( '.page-header', 'page_header_background', 'background' );
// Page Header font color.
$page_header_color = sinatra_option( 'page_header_text_color' );
// Page Header text color.
if ( isset( $page_header_color['text-color'] ) && $page_header_color['text-color'] ) {
$css .= '
.page-header .page-title {
color: ' . $page_header_color['text-color'] . '; }
.page-header .si-page-header-description {
color: ' . sinatra_hex2rgba( $page_header_color['text-color'], 0.75 ) . ';
}
';
}
// Page Header link color.
if ( isset( $page_header_color['link-color'] ) && $page_header_color['link-color'] ) {
$css .= '
.page-header .si-breadcrumbs a {
color: ' . $page_header_color['link-color'] . '; }
.page-header .si-breadcrumbs span,
.page-header .breadcrumb-trail .trail-items li::after, .page-header .si-breadcrumbs .separator {
color: ' . sinatra_hex2rgba( $page_header_color['link-color'], 0.75 ) . ';
}
';
}
// Page Header link hover color.
if ( isset( $page_header_color['link-hover-color'] ) && $page_header_color['link-hover-color'] ) {
$css .= '
.page-header .si-breadcrumbs a:hover {
color: ' . $page_header_color['link-hover-color'] . '; }
';
}
// Page Header border color.
$page_header_border = sinatra_option( 'page_header_border' );
$css .= $this->get_design_options_field_css( '.page-header', 'page_header_border', 'border' );
}
/**
* Breadcrumbs.
*/
if ( sinatra_option( 'breadcrumbs_enable' ) ) {
// Spacing.
$css .= $this->get_spacing_field_css( '.si-breadcrumbs', 'padding', 'breadcrumbs_spacing' );
if ( 'below-header' === sinatra_option( 'breadcrumbs_position' ) ) {
// Background.
$css .= $this->get_design_options_field_css( '.si-breadcrumbs', 'breadcrumbs_background', 'background' );
// Border.
$css .= $this->get_design_options_field_css( '.si-breadcrumbs', 'breadcrumbs_border', 'border' );
// Text Color.
$css .= $this->get_design_options_field_css( '.si-breadcrumbs', 'breadcrumbs_text_color', 'color' );
}
}
/**
* Copyright Bar.
*/
if ( sinatra_option( 'enable_copyright' ) ) {
$css .= $this->get_design_options_field_css( '#sinatra-copyright', 'copyright_background', 'background' );
// Copyright font color.
$copyright_color = sinatra_option( 'copyright_text_color' );
// Copyright text color.
if ( isset( $copyright_color['text-color'] ) && $copyright_color['text-color'] ) {
$css .= '
#sinatra-copyright {
color: ' . $copyright_color['text-color'] . '; }
';
}
// Copyright link color.
if ( isset( $copyright_color['link-color'] ) && $copyright_color['link-color'] ) {
$css .= '
#sinatra-copyright a {
color: ' . $copyright_color['link-color'] . '; }
';
}
// Copyright link hover color.
if ( isset( $copyright_color['link-hover-color'] ) && $copyright_color['link-hover-color'] ) {
$css .= '
#sinatra-copyright a:hover,
#sinatra-copyright .sinatra-social-nav > ul > li > a .si-icon.bottom-icon,
#sinatra-copyright .sinatra-nav > ul > li.current-menu-item > a,
#sinatra-copyright .sinatra-nav > ul > li.current-menu-ancestor > a,
#sinatra-copyright .sinatra-nav > ul > li:hover > a {
color: ' . $copyright_color['link-hover-color'] . '; }
';
}
// Copyright separator color.
$footer_text_color = sinatra_option( 'footer_text_color' );
$footer_text_color = $footer_text_color['text-color'];
$copyright_separator_color = sinatra_light_or_dark( $footer_text_color, 'rgba(255,255,255,0.1)', 'rgba(0,0,0,0.1)' );
$css .= '
#sinatra-copyright.contained-separator > .si-container::before {
background-color: ' . $copyright_separator_color . ';
}
#sinatra-copyright.fw-separator {
border-top-color: ' . $copyright_separator_color . ';
}
';
}
/**
* Typography.
*/
// Base HTML font size.
$css .= $this->get_range_field_css( 'html', 'font-size', 'html_base_font_size', true, 'px' );
// Font smoothing.
if ( sinatra_option( 'font_smoothing' ) ) {
$css .= '
* {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
';
}
// Body.
$css .= $this->get_typography_field_css( 'body', 'body_font' );
// Headings.
$css .= $this->get_typography_field_css( 'h1, .h1, .sinatra-logo .site-title, .page-header .page-title, h2, .h2, h3, .h3, h4, h5, h6', 'headings_font' );
$css .= $this->get_typography_field_css( 'h1, .h1, .sinatra-logo .site-title, .page-header .page-title', 'h1_font' );
$css .= $this->get_typography_field_css( 'h2, .h2', 'h2_font' );
$css .= $this->get_typography_field_css( 'h3, .h3', 'h3_font' );
$css .= $this->get_typography_field_css( 'h4', 'h4_font' );
$css .= $this->get_typography_field_css( 'h5', 'h5_font' );
$css .= $this->get_typography_field_css( 'h6', 'h6_font' );
$css .= $this->get_typography_field_css( 'h1 em, h2 em, h3 em, h4 em, h5 em, h6 em, .h1 em, .h2 em, .h3 em, .sinatra-logo .site-title em, .error-404 .page-header h1 em', 'heading_em_font' );
// Emphasized Heading.
$css .= $this->get_typography_field_css( 'h1 em, h2 em, h3 em, h4 em, h5 em, h6 em, .h1 em, .h2 em, .h3 em, .sinatra-logo .site-title em, .error-404 .page-header h1 em', 'heading_em_font' );
// Site Title font size.
$css .= $this->get_range_field_css( '#sinatra-header .sinatra-logo .site-title', 'font-size', 'logo_text_font_size', true );
// Sidebar widget title.
$css .= $this->get_range_field_css( '#main .widget-title', 'font-size', 'sidebar_widget_title_font_size', true );
// Footer widget title.
$css .= $this->get_range_field_css( '#colophon .widget-title', 'font-size', 'footer_widget_title_font_size', true );
// Blog Single Post - Title Spacing.
$css .= $this->get_spacing_field_css( '.si-single-title-in-page-header #page .page-header .si-page-header-wrapper', 'padding', 'single_title_spacing', true );
// Blog Single Post - Content Font Size.
$css .= $this->get_range_field_css( '.single-post .entry-content', 'font-size', 'single_content_font_size', true );
// Blog Single Post - narrow container.
if ( 'narrow' === sinatra_option( 'single_content_width' ) ) {
$css .= '
.single-post.narrow-content .entry-content > :not([class*="align"]):not([class*="gallery"]):not(.wp-block-image):not(.quote-inner):not(.quote-post-bg),
.single-post.narrow-content .mce-content-body:not([class*="page-template-full-width"]) > :not([class*="align"]):not([data-wpview-type*="gallery"]):not(blockquote):not(.mceTemp),
.single-post.narrow-content .entry-footer,
.single-post.narrow-content .entry-content > .alignwide,
.single-post.narrow-content p.has-background:not(.alignfull):not(.alignwide),
.single-post.narrow-content .post-nav,
.single-post.narrow-content #sinatra-comments-toggle,
.single-post.narrow-content #comments,
.single-post.narrow-content .entry-content .aligncenter, .single-post.narrow-content .si-narrow-element,
.single-post.narrow-content.si-single-title-in-content .entry-header,
.single-post.narrow-content.si-single-title-in-content .entry-meta,
.single-post.narrow-content.si-single-title-in-content .post-category,
.single-post.narrow-content.sinatra-no-sidebar .si-page-header-wrapper,
.single-post.narrow-content.sinatra-no-sidebar .si-breadcrumbs nav {
max-width: ' . sinatra_option( 'single_narrow_container_width' ) . 'px;
margin-left: auto;
margin-right: auto;
}
.single-post.narrow-content .author-box,
.single-post.narrow-content .entry-content > .alignwide,
.single.si-single-title-in-page-header .page-header.si-align-center .si-page-header-wrapper {
max-width: ' . ( intval( sinatra_option( 'single_narrow_container_width' ) ) + 70 ) . 'px;
}
';
}
// Allow CSS to be filtered.
$css = apply_filters( 'sinatra_dynamic_styles', $css );
// Add user custom CSS.
if ( $custom_css || ! is_customize_preview() ) {
$css .= wp_get_custom_css();
}
// Minify the CSS code.
$css = $this->minify( $css );
return $css;
}
/**
* Update dynamic css file with new CSS. Cleans caches after that.
*
* @return [Boolean] returns true if successfully updated the dynamic file.
*/
public function update_dynamic_file() {
$css = $this->get_css( true );
if ( empty( $css ) || '' === trim( $css ) ) {
return;
}
// Load file.php file.
require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'file.php'; // phpcs:ignore
global $wp_filesystem;
// Check if the the global filesystem isn't setup yet.
if ( is_null( $wp_filesystem ) ) {
WP_Filesystem();
}
$wp_filesystem->mkdir( $this->dynamic_css_path );
if ( $wp_filesystem->put_contents( $this->dynamic_css_path . 'dynamic-styles.css', $css ) ) {
$this->clean_cache();
set_transient( 'sinatra_has_dynamic_css', true, 0 );
return true;
}
return false;
}
/**
* Delete dynamic css file.
*
* @return void
*/
public function delete_dynamic_file() {
// Load file.php file.
require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'file.php'; // phpcs:ignore
global $wp_filesystem;
// Check if the the global filesystem isn't setup yet.
if ( is_null( $wp_filesystem ) ) {
WP_Filesystem();
}
$wp_filesystem->delete( $this->dynamic_css_path . 'dynamic-styles.css' );
delete_transient( 'sinatra_has_dynamic_css' );
}
/**
* Simple CSS code minification.
*
* @param string $css code to be minified.
* @return string, minifed code
* @since 1.0.0
*/
private function minify( $css ) {
$css = preg_replace( '/\s+/', ' ', $css );
$css = preg_replace( '/\/\*[^\!](.*?)\*\//', '', $css );
$css = preg_replace( '/(,|:|;|\{|}) /', '$1', $css );
$css = preg_replace( '/ (,|;|\{|})/', '$1', $css );
$css = preg_replace( '/(:| )0\.([0-9]+)(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}.${2}${3}', $css );
$css = preg_replace( '/(:| )(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}0', $css );
return trim( $css );
}
/**
* Cleans various caches. Compatible with cache plugins.
*
* @since 1.0.0
*/
private function clean_cache() {
// If W3 Total Cache is being used, clear the cache.
if ( function_exists( 'w3tc_pgcache_flush' ) ) {
w3tc_pgcache_flush();
}
// if WP Super Cache is being used, clear the cache.
if ( function_exists( 'wp_cache_clean_cache' ) ) {
global $file_prefix;
wp_cache_clean_cache( $file_prefix );
}
// If SG CachePress is installed, reset its caches.
if ( class_exists( 'SG_CachePress_Supercacher' ) ) {
if ( method_exists( 'SG_CachePress_Supercacher', 'purge_cache' ) ) {
SG_CachePress_Supercacher::purge_cache();
}
}
// Clear caches on WPEngine-hosted sites.
if ( class_exists( 'WpeCommon' ) ) {
if ( method_exists( 'WpeCommon', 'purge_memcached' ) ) {
WpeCommon::purge_memcached();
}
if ( method_exists( 'WpeCommon', 'clear_maxcdn_cache' ) ) {
WpeCommon::clear_maxcdn_cache();
}
if ( method_exists( 'WpeCommon', 'purge_varnish_cache' ) ) {
WpeCommon::purge_varnish_cache();
}
}
// Clean OpCache.
if ( function_exists( 'opcache_reset' ) ) {
opcache_reset(); // phpcs:ignore
}
// Clean WordPress cache.
if ( function_exists( 'wp_cache_flush' ) ) {
wp_cache_flush();
}
}
/**
* Prints spacing field CSS based on passed params.
*
* @since 1.0.0
*
* @param string $css_selector CSS selector.
* @param string $css_property CSS property, such as 'margin', 'padding' or 'border'.
* @param string $setting_id The ID of the customizer setting containing all information about the setting.
* @param bool $responsive Has responsive values.
* @return string Generated CSS.
*/
public function get_spacing_field_css( $css_selector, $css_property, $setting_id, $responsive = true ) {
// Get the saved setting.
$setting = sinatra_option( $setting_id );
// If setting doesn't exist, return.
if ( ! is_array( $setting ) ) {
return;
}
// Get the unit. Defaults to px.
$unit = 'px';
if ( isset( $setting['unit'] ) ) {
if ( $setting['unit'] ) {
$unit = $setting['unit'];
}
unset( $setting['unit'] );
}
// CSS buffer.
$css_buffer = '';
// Loop through options.
foreach ( $setting as $key => $value ) {
// Check if responsive options are available.
if ( is_array( $value ) ) {
if ( 'desktop' === $key ) {
$mq_open = '';
$mq_close = '';
} elseif ( 'tablet' === $key ) {
$mq_open = '@media only screen and (max-width: 768px) {';
$mq_close = '}';
} elseif ( 'mobile' === $key ) {
$mq_open = '@media only screen and (max-width: 480px) {';
$mq_close = '}';
} else {
$mq_open = '';
$mq_close = '';
}
// Add media query prefix.
$css_buffer .= $mq_open . $css_selector . '{';
// Loop through all choices.
foreach ( $value as $pos => $val ) {
if ( empty( $val ) ) {
continue;
}
if ( 'border' === $css_property ) {
$pos .= '-width';
}
$css_buffer .= $css_property . '-' . $pos . ': ' . intval( $val ) . $unit . ';';
}
$css_buffer .= '}' . $mq_close;
} else {
if ( 'border' === $css_property ) {
$key .= '-width';
}
$css_buffer .= $css_property . '-' . $key . ': ' . intval( $value ) . $unit . ';';
}
}
// Check if field is has responsive values.
if ( ! $responsive ) {
$css_buffer = $css_selector . '{' . $css_buffer . '}';
}
// Finally, return the generated CSS code.
return $css_buffer;
}
/**
* Prints range field CSS based on passed params.
*
* @since 1.0.0
*
* @param string $css_selector CSS selector.
* @param string $css_property CSS property, such as 'margin', 'padding' or 'border'.
* @param string $setting_id The ID of the customizer setting containing all information about the setting.
* @param bool $responsive Has responsive values.
* @param string $unit Unit.
* @return string Generated CSS.
*/
public function get_range_field_css( $css_selector, $css_property, $setting_id, $responsive = true, $unit = 'px' ) {
// Get the saved setting.
$setting = sinatra_option( $setting_id );
// If just a single value option.
if ( ! is_array( $setting ) ) {
return $css_selector . ' { ' . $css_property . ': ' . $setting . $unit . '; }';
}
// Resolve units.
if ( isset( $setting['unit'] ) ) {
if ( $setting['unit'] ) {
$unit = $setting['unit'];
}
unset( $setting['unit'] );
}
// CSS buffer.
$css_buffer = '';
if ( is_array( $setting ) && ! empty( $setting ) ) {
// Media query syntax wrap.
$mq_open = '';
$mq_close = '';
// Loop through options.
foreach ( $setting as $key => $value ) {
if ( empty( $value ) ) {
continue;
}
if ( 'desktop' === $key ) {
$mq_open = '';
$mq_close = '';
} elseif ( 'tablet' === $key ) {
$mq_open = '@media only screen and (max-width: 768px) {';
$mq_close = '}';
} elseif ( 'mobile' === $key ) {
$mq_open = '@media only screen and (max-width: 480px) {';
$mq_close = '}';
} else {
$mq_open = '';
$mq_close = '';
}
// Add media query prefix.
$css_buffer .= $mq_open . $css_selector . '{';
$css_buffer .= $css_property . ': ' . floatval( $value ) . $unit . ';';
$css_buffer .= '}' . $mq_close;
}
}
// Finally, return the generated CSS code.
return $css_buffer;
}
/**
* Prints design options field CSS based on passed params.
*
* @since 1.0.0
* @param string $css_selector CSS selector.
* @param string|mixed $setting The ID of the customizer setting containing all information about the setting.
* @param string $type Design options field type.
* @return string Generated CSS.
*/
public function get_design_options_field_css( $css_selector, $setting, $type ) {
if ( is_string( $setting ) ) {
// Get the saved setting.
$setting = sinatra_option( $setting );
}
// Setting has to be array.
if ( ! is_array( $setting ) || empty( $setting ) ) {
return;
}
// CSS buffer.
$css_buffer = '';
// Background.
if ( 'background' === $type ) {
// Background type.
$background_type = $setting['background-type'];
if ( 'color' === $background_type ) {
if ( isset( $setting['background-color'] ) && ! empty( $setting['background-color'] ) ) {
$css_buffer .= 'background: ' . $setting['background-color'] . ';';
}
} elseif ( 'gradient' === $background_type ) {
$css_buffer .= 'background: ' . $setting['gradient-color-1'] . ';';
if ( 'linear' === $setting['gradient-type'] ) {
$css_buffer .= '
background: -webkit-linear-gradient(' . $setting['gradient-linear-angle'] . 'deg, ' . $setting['gradient-color-1'] . ' ' . $setting['gradient-color-1-location'] . '%, ' . $setting['gradient-color-2'] . ' ' . $setting['gradient-color-2-location'] . '%);
background: -o-linear-gradient(' . $setting['gradient-linear-angle'] . 'deg, ' . $setting['gradient-color-1'] . ' ' . $setting['gradient-color-1-location'] . '%, ' . $setting['gradient-color-2'] . ' ' . $setting['gradient-color-2-location'] . '%);
background: linear-gradient(' . $setting['gradient-linear-angle'] . 'deg, ' . $setting['gradient-color-1'] . ' ' . $setting['gradient-color-1-location'] . '%, ' . $setting['gradient-color-2'] . ' ' . $setting['gradient-color-2-location'] . '%);
';
} elseif ( 'radial' === $setting['gradient-type'] ) {
$css_buffer .= '
background: -webkit-radial-gradient(' . $setting['gradient-position'] . ', circle, ' . $setting['gradient-color-1'] . ' ' . $setting['gradient-color-1-location'] . '%, ' . $setting['gradient-color-2'] . ' ' . $setting['gradient-color-2-location'] . '%);
background: -o-radial-gradient(' . $setting['gradient-position'] . ', circle, ' . $setting['gradient-color-1'] . ' ' . $setting['gradient-color-1-location'] . '%, ' . $setting['gradient-color-2'] . ' ' . $setting['gradient-color-2-location'] . '%);
background: radial-gradient(circle at ' . $setting['gradient-position'] . ', ' . $setting['gradient-color-1'] . ' ' . $setting['gradient-color-1-location'] . '%, ' . $setting['gradient-color-2'] . ' ' . $setting['gradient-color-2-location'] . '%);
';
}
} elseif ( 'image' === $background_type ) {
$css_buffer .= '
background-image: url(' . $setting['background-image'] . ');
background-size: ' . $setting['background-size'] . ';
background-attachment: ' . $setting['background-attachment'] . ';
background-position: ' . $setting['background-position-x'] . '% ' . $setting['background-position-y'] . '%;
background-repeat: ' . $setting['background-repeat'] . ';
';
}
$css_buffer = ! empty( $css_buffer ) ? $css_selector . '{' . $css_buffer . '}' : '';
if ( 'image' === $background_type && isset( $setting['background-color-overlay'] ) && $setting['background-color-overlay'] && isset( $setting['background-image'] ) && $setting['background-image'] ) {
$css_buffer .= $css_selector . '::after { background-color: ' . $setting['background-color-overlay'] . '; }';
}
} elseif ( 'color' === $type ) {
// Text color.
if ( isset( $setting['text-color'] ) && ! empty( $setting['text-color'] ) ) {
$css_buffer .= $css_selector . ' { color: ' . $setting['text-color'] . '; }';
}
// Link Color.
if ( isset( $setting['link-color'] ) && ! empty( $setting['link-color'] ) ) {
$css_buffer .= $css_selector . ' a { color: ' . $setting['link-color'] . '; }';
}
// Link Hover Color.
if ( isset( $setting['link-hover-color'] ) && ! empty( $setting['link-hover-color'] ) ) {
$css_buffer .= $css_selector . ' a:hover { color: ' . $setting['link-hover-color'] . ' !important; }';
}
} elseif ( 'border' === $type ) {
// Color.
if ( isset( $setting['border-color'] ) && ! empty( $setting['border-color'] ) ) {
$css_buffer .= 'border-color:' . $setting['border-color'] . ';';
}
// Style.
if ( isset( $setting['border-style'] ) && ! empty( $setting['border-style'] ) ) {
$css_buffer .= 'border-style: ' . $setting['border-style'] . ';';
}
// Width.
$positions = array( 'top', 'right', 'bottom', 'left' );
foreach ( $positions as $position ) {
if ( isset( $setting[ 'border-' . $position . '-width' ] ) && ! empty( $setting[ 'border-' . $position . '-width' ] ) ) {
$css_buffer .= 'border-' . $position . '-width: ' . $setting[ 'border-' . $position . '-width' ] . 'px;';
}
}
$css_buffer = ! empty( $css_buffer ) ? $css_selector . '{' . $css_buffer . '}' : '';
} elseif ( 'separator_color' === $type && isset( $setting['separator-color'] ) && ! empty( $setting['separator-color'] ) ) {
// Separator Color.
$css_buffer .= $css_selector . '::after { background-color:' . $setting['separator-color'] . '; }';
}
// Finally, return the generated CSS code.
return $css_buffer;
}
/**
* Prints typography field CSS based on passed params.
*
* @since 1.0.0
* @param string $css_selector CSS selector.
* @param string|mixed $setting The ID of the customizer setting containing all information about the setting.
* @return string Generated CSS.
*/
public function get_typography_field_css( $css_selector, $setting ) {
if ( is_string( $setting ) ) {
// Get the saved setting.
$setting = sinatra_option( $setting );
}
// Setting has to be array.
if ( ! is_array( $setting ) || empty( $setting ) ) {
return;
}
// CSS buffer.
$css_buffer = '';
// Properties.
$properties = array(
'font-weight',
'font-style',
'text-transform',
'text-decoration',
);
foreach ( $properties as $property ) {
if ( 'inherit' !== $setting[ $property ] ) {
$css_buffer .= $property . ':' . $setting[ $property ] . ';';
}
}
// Font family.
if ( 'inherit' !== $setting['font-family'] ) {
$font_family = sinatra()->fonts->get_font_family( $setting['font-family'] );
$css_buffer .= 'font-family: ' . $font_family . ';';
}
// Letter spacing.
if ( ! empty( $setting['letter-spacing'] ) ) {
$css_buffer .= 'letter-spacing:' . $setting['letter-spacing'] . $setting['letter-spacing-unit'] . ';';
}
// Font size.
if ( ! empty( $setting['font-size-desktop'] ) ) {
$css_buffer .= 'font-size:' . $setting['font-size-desktop'] . $setting['font-size-unit'] . ';';
}
// Line Height.
if ( ! empty( $setting['line-height-desktop'] ) ) {
$css_buffer .= 'line-height:' . $setting['line-height-desktop'] . ';';
}
$css_buffer = $css_buffer ? $css_selector . '{' . $css_buffer . '}' : '';
// Responsive options - tablet.
$tablet = '';
if ( ! empty( $setting['font-size-tablet'] ) ) {
$tablet .= 'font-size:' . $setting['font-size-tablet'] . $setting['font-size-unit'] . ';';
}
if ( ! empty( $setting['line-height-tablet'] ) ) {
$tablet .= 'line-height:' . $setting['line-height-tablet'] . ';';
}
$tablet = ! empty( $tablet ) ? '@media only screen and (max-width: 768px) {' . $css_selector . '{' . $tablet . '} }' : '';
$css_buffer .= $tablet;
// Responsive options - mobile.
$mobile = '';
if ( ! empty( $setting['font-size-mobile'] ) ) {
$mobile .= 'font-size:' . $setting['font-size-mobile'] . $setting['font-size-unit'] . ';';
}
if ( ! empty( $setting['line-height-mobile'] ) ) {
$mobile .= 'line-height:' . $setting['line-height-mobile'] . ';';
}
$mobile = ! empty( $mobile ) ? '@media only screen and (max-width: 480px) {' . $css_selector . '{' . $mobile . '} }' : '';
$css_buffer .= $mobile;
// Equeue google fonts.
if ( sinatra()->fonts->is_google_font( $setting['font-family'] ) ) {
$params = array();
if ( 'inherit' !== $setting['font-weight'] ) {
$params['weight'] = $setting['font-weight'];
}
if ( 'inherit' !== $setting['font-style'] ) {
$params['style'] = $setting['font-style'];
}
if ( $setting['font-subsets'] && ! empty( $setting['font-subsets'] ) ) {
$params['subsets'] = $setting['font-subsets'];
}
sinatra()->fonts->enqueue_google_font(
$setting['font-family'],
$params
);
}
// Finally, return the generated CSS code.
return $css_buffer;
}
/**
* Filters the dynamic styles to include button styles and makes sure it has the highest priority.
*
* @since 1.0.0
* @param string $css The dynamic CSS.
* @return string Filtered dynamic CSS.
*/
public function get_button_styles( $css ) {
/**
* Primary Button.
*/
$primary_button_selector = '
.si-btn,
body:not(.wp-customizer) input[type=submit],
.site-main .woocommerce #respond input#submit,
.site-main .woocommerce a.button,
.site-main .woocommerce button.button,
.site-main .woocommerce input.button,
.woocommerce ul.products li.product .added_to_cart,
.woocommerce ul.products li.product .button,
.woocommerce div.product form.cart .button,
.woocommerce #review_form #respond .form-submit input,
#infinite-handle span';
$primary_button_bg_color = sinatra_option( 'primary_button_bg_color' );
$primary_button_border_radius = sinatra_option( 'primary_button_border_radius' );
if ( '' !== $primary_button_bg_color ) {
$css .= $primary_button_selector . ' {
background-color: ' . $primary_button_bg_color . ';
}';
}
// Primary button text color, border color & border width.
$css .= $primary_button_selector . ' {
color: ' . sinatra_option( 'primary_button_text_color' ) . ';
border-color: ' . sinatra_option( 'primary_button_border_color' ) . ';
border-width: ' . sinatra_option( 'primary_button_border_width' ) . 'px;
border-top-left-radius: ' . $primary_button_border_radius['top-left'] . 'px;
border-top-right-radius: ' . $primary_button_border_radius['top-right'] . 'px;
border-bottom-right-radius: ' . $primary_button_border_radius['bottom-right'] . 'px;
border-bottom-left-radius: ' . $primary_button_border_radius['bottom-left'] . 'px;
}';
// Primary button hover.
$primary_button_hover_selector = '
.si-btn:hover,
.si-btn:focus,
body:not(.wp-customizer) input[type=submit]:hover,
body:not(.wp-customizer) input[type=submit]:focus,
.site-main .woocommerce #respond input#submit:hover,
.site-main .woocommerce #respond input#submit:focus,
.site-main .woocommerce a.button:hover,
.site-main .woocommerce a.button:focus,
.site-main .woocommerce button.button:hover,
.site-main .woocommerce button.button:focus,
.site-main .woocommerce input.button:hover,
.site-main .woocommerce input.button:focus,
.woocommerce ul.products li.product .added_to_cart:hover,
.woocommerce ul.products li.product .added_to_cart:focus,
.woocommerce ul.products li.product .button:hover,
.woocommerce ul.products li.product .button:focus,
.woocommerce div.product form.cart .button:hover,
.woocommerce div.product form.cart .button:focus,
.woocommerce #review_form #respond .form-submit input:hover,
.woocommerce #review_form #respond .form-submit input:focus,
#infinite-handle span:hover';
$primary_button_hover_bg_color = sinatra_option( 'primary_button_hover_bg_color' );
// Primary button hover bg color.
if ( '' !== $primary_button_hover_bg_color ) {
$css .= $primary_button_hover_selector . ' {
background-color: ' . $primary_button_hover_bg_color . ';
}';
}
// Primary button hover color & border.
$css .= $primary_button_hover_selector . '{
color: ' . sinatra_option( 'primary_button_hover_text_color' ) . ';
border-color: ' . sinatra_option( 'primary_button_hover_border_color' ) . ';
}';
// Primary button typography.
$css .= $this->get_typography_field_css( $primary_button_selector, 'primary_button_typography' );
/**
* Secondary Button.
*/
$secondary_button_selector = '
.btn-secondary,
.si-btn.btn-secondary';
$secondary_button_bg_color = sinatra_option( 'secondary_button_bg_color' );
$secondary_button_border_radius = sinatra_option( 'secondary_button_border_radius' );
// Secondary button text color, border color & border width.
$css .= $secondary_button_selector . ' {
color: ' . sinatra_option( 'secondary_button_text_color' ) . ';
border-color: ' . sinatra_option( 'secondary_button_border_color' ) . ';
border-width: ' . sinatra_option( 'secondary_button_border_width' ) . 'px;
background-color: ' . $secondary_button_bg_color . ';
border-top-left-radius: ' . $secondary_button_border_radius['top-left'] . 'px;
border-top-right-radius: ' . $secondary_button_border_radius['top-right'] . 'px;
border-bottom-right-radius: ' . $secondary_button_border_radius['bottom-right'] . 'px;
border-bottom-left-radius: ' . $secondary_button_border_radius['bottom-left'] . 'px;
}';
// Secondary button hover.
$secondary_button_hover_selector = '
.btn-secondary:hover,
.btn-secondary:focus,
.si-btn.btn-secondary:hover,
.si-btn.btn-secondary:focus';
$secondary_button_hover_bg_color = sinatra_option( 'secondary_button_hover_bg_color' );
// Secondary button hover color & border.
$css .= $secondary_button_hover_selector . '{
color: ' . sinatra_option( 'secondary_button_hover_text_color' ) . ';
border-color: ' . sinatra_option( 'secondary_button_hover_border_color' ) . ';
background-color: ' . $secondary_button_hover_bg_color . ';
}';
// Secondary button typography.
$css .= $this->get_typography_field_css( $secondary_button_selector, 'secondary_button_typography' );
// Text Button.
$css .= '
.si-btn.btn-text-1, .btn-text-1 {
color: ' . sinatra_option( 'text_button_text_color' ) . ';
}
';
$css .= '
.si-btn.btn-text-1:hover, .si-btn.btn-text-1:focus, .btn-text-1:hover, .btn-text-1:focus {
color: ' . sinatra_option( 'accent_color' ) . ';
}
';
$css .= '
.si-btn.btn-text-1 > span::before {
background-color: ' . sinatra_option( 'accent_color' ) . ';
}
';
if ( sinatra_option( 'text_button_hover_text_color' ) ) {
$css .= '
.si-btn.btn-text-1:hover, .si-btn.btn-text-1:focus, .btn-text-1:hover, .btn-text-1:focus {
color: ' . sinatra_option( 'text_button_hover_text_color' ) . ';
}
.si-btn.btn-text-1 > span::before {
background-color: ' . sinatra_option( 'text_button_hover_text_color' ) . ';
}
';
}
// Secondary button typography.
$css .= $this->get_typography_field_css( '.si-btn.btn-text-1, .btn-text-1', 'text_button_typography' );
// Return the filtered CSS.
return $css;
}
/**
* Generate dynamic Block Editor styles.
*
* @since 1.0.9
* @return string
*/
public function get_block_editor_css() {
// Current post.
$post_id = get_the_ID();
$post_type = get_post_type( $post_id );
// Layout.
$site_layout = sinatra_get_site_layout( $post_id );
$sidebar_position = sinatra_get_sidebar_position( $post_id );
$container_width = sinatra_option( 'container_width' );
$single_content_width = sinatra_option( 'single_content_width' );
$container_width = $container_width - 100;
if ( sinatra_is_sidebar_displayed( $post_id ) ) {
$sidebar_width = sinatra_option( 'sidebar_width' );
$container_width = $container_width * ( 100 - intval( $sidebar_width ) ) / 100;
$container_width = $container_width - 50;
if ( 'boxed-separated' === $site_layout ) {
if ( 3 === intval( sinatra_option( 'sidebar_style' ) ) ) {
$container_width += 15;
}
}
}
if ( 'boxed-separated' === $site_layout ) {
$container_width += 16;
}
if ( 'boxed' === $site_layout ) {
$container_width = $container_width + 200;
}
$background_color = get_background_color();
$accent_color = sinatra_option( 'accent_color' );
$content_color = sinatra_option( 'boxed_content_background_color' );
$text_color = sinatra_option( 'content_text_color' );
$link_hover_color = sinatra_option( 'content_link_hover_color' );
$headings_color = sinatra_option( 'headings_color' );
$font_smoothing = sinatra_option( 'font_smoothing' );
$css = '';
// Base HTML font size.
$css .= $this->get_range_field_css( 'html', 'font-size', 'html_base_font_size', true, 'px' );
// Accent color.
$css .= '
.editor-styles-wrapper .block-editor-rich-text__editable mark,
.editor-styles-wrapper .block-editor-rich-text__editable span.highlight,
.editor-styles-wrapper .block-editor-rich-text__editable code,
.editor-styles-wrapper .block-editor-rich-text__editable kbd,
.editor-styles-wrapper .block-editor-rich-text__editable var,
.editor-styles-wrapper .block-editor-rich-text__editable samp,
.editor-styles-wrapper .block-editor-rich-text__editable tt {
background-color: ' . sinatra_hex2rgba( $accent_color, .09 ) . ';
}
.editor-styles-wrapper .wp-block code.block,
.editor-styles-wrapper .block code {
background-color: ' . sinatra_hex2rgba( $accent_color, .075 ) . ';
}
.editor-styles-wrapper .wp-block .block-editor-rich-text__editable a,
.editor-styles-wrapper .block-editor-rich-text__editable code,
.editor-styles-wrapper .block-editor-rich-text__editable kbd,
.editor-styles-wrapper .block-editor-rich-text__editable var,
.editor-styles-wrapper .block-editor-rich-text__editable samp,
.editor-styles-wrapper .block-editor-rich-text__editable tt {
color: ' . $accent_color . ';
}
#editor .editor-styles-wrapper ::-moz-selection { background-color: ' . $accent_color . '; color: #FFF; }
#editor .editor-styles-wrapper ::selection { background-color: ' . $accent_color . '; color: #FFF; }
.editor-styles-wrapper blockquote,
.editor-styles-wrapper .wp-block-quote {
border-color: ' . $accent_color . ';
}
';
// Container width.
if ( 'fw-stretched' === $site_layout ) {
$css .= '
.editor-styles-wrapper .wp-block {
max-width: none;
}
';
} elseif ( 'boxed-separated' === $site_layout || 'boxed' === $site_layout ) {
$css .= '
.editor-styles-wrapper {
max-width: ' . $container_width . 'px;
margin: 0 auto;
}
.editor-styles-wrapper .wp-block {
max-width: none;
}
';
if ( 'boxed' === $site_layout ) {
$css .= '
.editor-styles-wrapper {
-webkit-box-shadow: 0 0 30px rgba(50, 52, 54, 0.06);
box-shadow: 0 0 30px rgba(50, 52, 54, 0.06);
padding-left: 42px;
padding-right: 42px;
}
';
} else {
$css .= '
.editor-styles-wrapper {
border-radius: 3px;
border: 1px solid rgba(0, 0, 0, 0.085);
}
';
}
} else {
$css .= '
.editor-styles-wrapper .wp-block {
max-width: ' . $container_width . 'px;
}
';
}
if ( 'post' === $post_type && 'narrow' === $single_content_width ) {
$narrow_container_width = intval( sinatra_option( 'single_narrow_container_width' ) );
$css .= '
.editor-styles-wrapper .wp-block {
max-width: ' . $narrow_container_width . 'px;
}
';
}
// Background color.
if ( 'boxed-separated' === $site_layout || 'boxed' === $site_layout ) {
$css .= '
:root .edit-post-layout .interface-interface-skeleton__content {
background-color: #' . trim( $background_color, '#' ) . ';
}
:root .editor-styles-wrapper {
background-color: ' . $content_color . ';
}
';
} else {
$css .= '
:root .editor-styles-wrapper {
background-color: #' . trim( $background_color, '#' ) . ';
}
';
}
// Body.
$css .= $this->get_typography_field_css( ':root .editor-styles-wrapper, .editor-styles-wrapper .wp-block, .block-editor-default-block-appender textarea.block-editor-default-block-appender__content', 'body_font' );
$css .= '
:root .editor-styles-wrapper {
color: ' . $text_color . ';
}
';
// If single post, use single post font size settings.
if ( 'post' === $post_type ) {
$css .= $this->get_range_field_css( ':root .editor-styles-wrapper .wp-block', 'font-size', 'single_content_font_size', true );
}
// Headings typography.
$css .= $this->get_typography_field_css( ':root .editor-styles-wrapper h1.wp-block, :root .editor-styles-wrapper h2.wp-block, :root .editor-styles-wrapper h3.wp-block, :root .editor-styles-wrapper h4.wp-block, :root .editor-styles-wrapper h5.wp-block, :root .editor-styles-wrapper h6.wp-block, :root .editor-styles-wrapper .editor-post-title__block .editor-post-title__input', 'headings_font' );
// Heading em.
$css .= $this->get_typography_field_css( '.editor-styles-wrapper h1.wp-block em, .editor-styles-wrapper h2.wp-block em, .editor-styles-wrapper h3.wp-block em, .editor-styles-wrapper h4.wp-block em, .editor-styles-wrapper h5.wp-block em, .editor-styles-wrapper h6.wp-block em', 'heading_em_font' );
// Headings (H1-H6).
$css .= $this->get_typography_field_css( ':root .editor-styles-wrapper h1.wp-block, :root .editor-styles-wrapper .h1, :root .editor-styles-wrapper .editor-post-title__block .editor-post-title__input', 'h1_font' );
$css .= $this->get_typography_field_css( ':root .editor-styles-wrapper h2.wp-block, :root .editor-styles-wrapper .h2', 'h2_font' );
$css .= $this->get_typography_field_css( ':root .editor-styles-wrapper h3.wp-block, :root .editor-styles-wrapper .h3', 'h3_font' );
$css .= $this->get_typography_field_css( ':root .editor-styles-wrapper h4.wp-block', 'h4_font' );
$css .= $this->get_typography_field_css( ':root .editor-styles-wrapper h5.wp-block', 'h5_font' );
$css .= $this->get_typography_field_css( ':root .editor-styles-wrapper h6.wp-block', 'h6_font' );
$css .= '
:root .editor-styles-wrapper h1,
:root .editor-styles-wrapper h2,
:root .editor-styles-wrapper h3,
:root .editor-styles-wrapper h4,
:root .editor-styles-wrapper h5,
:root .editor-styles-wrapper h6,
:root .editor-post-title__block .editor-post-title__input {
color: ' . $headings_color . ';
}
';
// Page header font size.
$css .= $this->get_range_field_css( ':root .editor-styles-wrapper .editor-post-title__block .editor-post-title__input', 'font-size', 'page_header_font_size', true );
// Link hover color.
$css .= '
.editor-styles-wrapper .wp-block .block-editor-rich-text__editable a:hover {
color: ' . $link_hover_color . ';
}
';
// Font smoothing.
if ( $font_smoothing ) {
$css .= '
.editor-styles-wrapper {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
';
}
return $css;
}
}
endif;
/**
* The function which returns the one Sinatra_Dynamic_Styles instance.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* Example:
*
* @since 1.0.0
* @return object
*/
function sinatra_dynamic_styles() {
return Sinatra_Dynamic_Styles::instance();
}
sinatra_dynamic_styles();
common.php 0000644 00000057165 15123153670 0006566 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'sinatra_get_allowed_html_tags' ) ) {
/**
* Array of allowed HTML Tags.
*
* @since 1.0.0
* @param string $type predefined HTML tags group name.
* @return array, allowed HTML tags.
*/
function sinatra_get_allowed_html_tags( $type = 'basic' ) {
$tags = array();
switch ( $type ) {
case 'basic':
$tags = array(
'strong' => array(),
'em' => array(),
'b' => array(),
'br' => array(),
'i' => array(
'class' => array(),
),
'img' => array(
'src' => array(),
'alt' => array(),
'width' => array(),
'height' => array(),
'class' => array(),
'id' => array(),
),
'span' => array(
'class' => array(),
),
'a' => array(
'href' => array(),
'rel' => array(),
'target' => array(),
'class' => array(),
'role' => array(),
'id' => array(),
),
);
break;
case 'button':
$tags = array(
'strong' => array(),
'em' => array(),
'span' => array(
'class' => array(),
),
'i' => array(
'class' => array(),
),
);
break;
case 'span':
$tags = array(
'span' => array(
'class' => array(),
),
);
break;
case 'icon':
$tags = array(
'i' => array(),
'span' => array(),
'img' => array(),
);
break;
default:
$tags = array(
'strong' => array(),
'em' => array(),
'b' => array(),
'i' => array(),
'img' => array(
'src' => array(),
'alt' => array(),
'width' => array(),
'height' => array(),
'class' => array(),
'id' => array(),
),
'span' => array(),
'a' => array(
'href' => array(),
'rel' => array(),
'target' => array(),
'class' => array(),
'role' => array(),
'id' => array(),
),
);
break;
}
return apply_filters( 'sinatra_allowed_html_tags', $tags, $type );
}
}
/**
* Returns the value for option.
*
* @since 1.0.0
*
* @param string $id Option ID.
* @param string $prefix Theme prefix.
* @param string $type Option or Theme Mod.
* @return mixed Option value.
*/
function sinatra_option( $id, $prefix = 'sinatra_', $type = 'theme_mod' ) {
if ( 'theme_mod' === $type ) {
return sinatra()->options->get( $prefix . $id );
} else {
return get_option( $prefix . $id, sinatra()->options->get( $prefix . $id ) );
}
}
/**
* Get default for option.
*
* @since 1.1.0
*
* @param string $id Option ID.
* @param string $prefix Theme prefix.
* @return mixed Option value.
*/
function sinatra_get_default( $id, $prefix = 'sinatra_' ) {
return sinatra()->options->get_default( $prefix . $id );
}
/**
* Checks to see if Top Bar is enabled.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean if Top Bar is enabled.
*/
function sinatra_is_top_bar_displayed( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$top_bar_displayed = sinatra_option( 'top_bar_enable' );
if ( $post_id && $top_bar_displayed ) {
$top_bar_displayed = ! get_post_meta( $post_id, 'sinatra_disable_topbar', true );
}
// Do not show top bar on 404 page.
if ( is_404() ) {
$top_bar_displayed = false;
}
return apply_filters( 'sinatra_is_top_bar_displayed', $top_bar_displayed, $post_id );
}
/**
* Checks to see if Page Preloader is displayed.
*
* @since 1.0.0
*
* @return boolean, true if Preloader is displayed.
*/
function sinatra_is_preloader_displayed() {
$displayed = (bool) sinatra_option( 'preloader' );
return apply_filters( 'sinatra_is_preloader_displayed', $displayed );
}
/**
* Checks to see if Header is displayed.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean true if Header is displayed.
*/
function sinatra_is_header_displayed( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$displayed = true;
if ( $post_id ) {
$displayed = ! get_post_meta( $post_id, 'sinatra_disable_header', true );
}
return apply_filters( 'sinatra_is_header_displayed', $displayed, $post_id );
}
/**
* Checks to see if Transparent Header is enabled.
*
* @since 1.0.0
* @param int $post_id Optional. The post ID to check.
* @return boolean, true if Header is transparent.
*/
function sinatra_is_header_transparent( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$enabled = sinatra_option( 'tsp_header' );
if ( $enabled && sinatra_is_section_disabled( sinatra_option( 'tsp_header_disable_on' ), $post_id ) ) {
$enabled = false;
}
if ( $post_id ) {
$_meta = get_post_meta( $post_id, 'sinatra_transparent_header', true );
if ( 'enable' === $_meta ) {
$enabled = true;
} elseif ( 'disable' === $_meta ) {
$enabled = false;
}
}
return apply_filters( 'sinatra_transparent_header', $enabled, $post_id );
}
/**
* Checks to see if Pre Footer is enabled.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean true if Pre Footer is enabled.
*/
function sinatra_is_pre_footer_displayed( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$displayed = false;
// Customizer option to enable pre-footer.
if ( sinatra_option( 'enable_pre_footer_cta' ) ) {
$displayed = true;
}
// At least one pre-footer are has to be enabled.
if ( ! sinatra_is_pre_footer_cta_displayed( $post_id ) ) {
$displayed = false;
}
return apply_filters( 'sinatra_is_pre_footer_displayed', $displayed, $post_id );
}
/**
* Checks to see if Pre Footer is enabled.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean True if Pre Footer is enabled.
*/
function sinatra_is_pre_footer_cta_displayed( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$displayed = false;
if ( sinatra_option( 'enable_pre_footer_cta' ) ) {
$displayed = true;
}
if ( $displayed && sinatra_is_section_disabled( sinatra_option( 'pre_footer_cta_hide_on' ), $post_id ) ) {
$displayed = false;
}
if ( $post_id && $displayed ) {
$displayed = ! get_post_meta( $post_id, 'sinatra_disable_prefooter_cta', true );
}
// Do not show pre footer widgets on 404 page.
if ( is_404() ) {
$displayed = false;
}
return apply_filters( 'sinatra_is_pre_footer_cta_displayed', $displayed, $post_id );
}
/**
* Checks to see if Hero section is enabled.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean True if Hero is enabled.
*/
function sinatra_is_hero_displayed( $post_id = 0 ) {
$displayed = true;
if ( ! sinatra_option( 'enable_hero' ) ) {
$displayed = false;
}
if ( $displayed && ! sinatra_is_section_disabled( sinatra_option( 'hero_enable_on' ), $post_id ) ) {
$displayed = false;
}
return apply_filters( 'sinatra_is_hero_displayed', $displayed, $post_id );
}
/**
* Checks to see if Main Footer is enabled.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean, true if Main Footer is enabled.
*/
function sinatra_is_footer_displayed( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$footer_displayed = sinatra_option( 'enable_footer' );
if ( $post_id && $footer_displayed ) {
$footer_displayed = ! get_post_meta( $post_id, 'sinatra_disable_footer', true );
}
// Do not show footer widgets on 404 page.
if ( is_404() ) {
$footer_displayed = false;
}
if ( $footer_displayed && ! current_user_can( 'edit_theme_options' ) ) {
$footer_columns = sinatra_get_footer_column_count();
$footer_active = false;
for ( $i = 1; $i <= $footer_columns; $i++ ) {
$footer_active = $footer_active || is_active_sidebar( 'sinatra-footer-' . $i );
}
$footer_displayed = $footer_displayed && $footer_active;
}
return apply_filters( 'sinatra_is_footer_displayed', $footer_displayed, $post_id );
}
/**
* Checks to see if Copyright Bar is enabled.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean, true if Copyright bar is enabled.
*/
function sinatra_is_copyright_bar_displayed( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$displayed = sinatra_option( 'enable_copyright' );
$widgets = sinatra_option( 'copyright_widgets' );
if ( $displayed && ! is_array( $widgets ) || empty( $widgets ) ) {
$displayed = false;
}
if ( $post_id && $displayed ) {
$displayed = ! get_post_meta( $post_id, 'sinatra_disable_copyright', true );
}
// Do not show copyright bar on 404 page.
if ( is_404() ) {
$displayed = false;
}
return apply_filters( 'sinatra_is_copyright_displayed', $displayed, $post_id );
}
/**
* Checks to see if Colophon section is enabled.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean, true if Colophon is enabled.
*/
function sinatra_is_colophon_displayed( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$displayed = true;
// Do not show colophon if both footer and copyright bar are not displayed.
if ( ! sinatra_is_footer_displayed( $post_id ) && ! sinatra_is_copyright_bar_displayed( $post_id ) ) {
$displayed = false;
}
// Do not show colophon on 404 page.
if ( is_404() ) {
$displayed = false;
}
return apply_filters( 'sinatra_is_colophon_displayed', $displayed, $post_id );
}
/**
* Checks to see if Page Header is displayed.
*
* @since 1.0.0
*
* @param int $post_id Optional. The post ID to check.
* @return boolean, if Page Header is displayed.
*/
function sinatra_is_page_header_displayed( $post_id = 0 ) {
if ( ! $post_id ) {
$post_id = sinatra_get_the_id();
}
$displayed = sinatra_option( 'page_header_enable' );
if ( $post_id && $displayed ) {
$displayed = sinatra_page_header_has_title( $post_id ) || sinatra_page_header_has_breadcrumbs( $post_id );
} elseif ( is_404() ) {
$displayed = false;
}
if ( is_front_page() ) {
$displayed = false;
}
return apply_filters( 'sinatra_is_page_header_displayed', $displayed, $post_id );
}
/**
* Checks to see if WooCommerce is installed & activated.
*
* @since 1.0.0
* @return boolean, if Copyright bar is enabled.
*/
function sinatra_is_woocommerce_activated() {
return class_exists( 'woocommerce' );
}
/**
* Get registered sidebar name by sidebar ID.
*
* @since 1.0.0
* @param string $sidebar_id Sidebar ID.
* @return string Sidebar name.
*/
function sinatra_get_sidebar_name_by_id( $sidebar_id = '' ) {
if ( ! $sidebar_id ) {
return;
}
global $wp_registered_sidebars;
$sidebar_name = '';
if ( isset( $wp_registered_sidebars[ $sidebar_id ] ) ) {
$sidebar_name = $wp_registered_sidebars[ $sidebar_id ]['name'];
}
return $sidebar_name;
}
/**
* Convert hexdec color string to rgb(a) string.
*
* @since 1.0.0
* @param string $color Hex color code.
* @param string | boolean $opacity opacity value.
* @return string color in rgba format.
*/
function sinatra_hex2rgba( $color, $opacity = false ) {
$default = 'rgb(0,0,0)';
// Return default if no color provided.
if ( empty( $color ) ) {
return $default;
}
if ( substr( $color, 0, 4 ) === 'rgba' ) {
return $color;
}
// Sanitize $color if "#" is provided.
if ( '#' === $color[0] ) {
$color = substr( $color, 1 );
}
// Check if color has 6 or 3 characters and get values.
if ( 6 === strlen( $color ) ) {
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
} elseif ( 3 === strlen( $color ) ) {
$hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
} else {
return $default;
}
// Convert hexadec to rgb.
$rgb = array_map( 'hexdec', $hex );
// Check if opacity is set(rgba or rgb).
if ( $opacity ) {
if ( abs( $opacity ) > 1 ) {
$opacity = 1;
}
$output = 'rgba(' . implode( ',', $rgb ) . ',' . $opacity . ')';
} else {
$output = 'rgb(' . implode( ',', $rgb ) . ')';
}
// Return rgb(a) color string.
return $output;
}
/**
* Convert rgb(a) color string to hex string.
*
* @since 1.0.0
* @param string $color rgb(a) color code.
* @return string color in HEX format.
*/
function sinatra_rgba2hex( $color ) {
preg_match( '/rgba?\(\s?([0-9]{1,3}),\s?([0-9]{1,3}),\s?([0-9]{1,3})/i', $color, $matches );
if ( ! is_array( $matches ) || count( $matches ) < 3 ) {
return false;
}
$hex = '';
for ( $i = 1; $i <= 3; $i++ ) {
$x = dechex( (int) $matches[ $i ] );
$hex .= ( 1 === strlen( $x ) ) ? '0' . $x : $x;
}
if ( $hex ) {
return '#' . $hex;
}
return false;
}
/**
* Lightens/darkens a given colour (in hex format), returning the altered color in hex format.
*
* @since 1.0.0
* @param string $hexcolor Color as hexadecimal (with or without hash).
* @param float $percent Decimal ( 0.2 = lighten by 20%, -0.4 = darken by 40% ).
* @return string Lightened/Darkend color as hexadecimal (with hash)
*/
function sinatra_luminance( $hexcolor, $percent ) {
if ( empty( $hexcolor ) ) {
return;
}
// Check if color is in RGB format and convert to HEX.
if ( false !== strpos( $hexcolor, 'rgb' ) ) {
$hexcolor = sinatra_rgba2hex( $hexcolor );
}
if ( strlen( $hexcolor ) < 6 ) {
$hexcolor = $hexcolor[0] . $hexcolor[0] . $hexcolor[1] . $hexcolor[1] . $hexcolor[2] . $hexcolor[2];
}
$hexcolor = array_map( 'hexdec', str_split( str_pad( str_replace( '#', '', $hexcolor ), 6, '0' ), 2 ) );
foreach ( $hexcolor as $i => $color ) {
$from = $percent < 0 ? 0 : $color;
$to = $percent < 0 ? $color : 255;
$pvalue = ceil( ( $to - $from ) * $percent );
$hexcolor[ $i ] = str_pad( dechex( $color + $pvalue ), 2, '0', STR_PAD_LEFT );
}
// Return hex color.
return '#' . implode( $hexcolor );
}
/**
* Determine whether a hex color is light.
*
* @param mixed $color Color.
* @return bool True if a light color.
*/
function sinatra_is_light_color( $color ) {
// Ensure we color is in hex format.
if ( false !== strpos( $color, 'rgb' ) ) {
$color = sinatra_rgba2hex( $color );
}
$hex = str_replace( '#', '', $color );
$c_r = hexdec( substr( $hex, 0, 2 ) );
$c_g = hexdec( substr( $hex, 2, 2 ) );
$c_b = hexdec( substr( $hex, 4, 2 ) );
$brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
return $brightness > 155;
}
/**
* Detect if we should use a light or dark color on a background color.
*
* @param mixed $color Color.
* @param string $dark Darkest reference. Defaults to '#000000'.
* @param string $light Lightest reference. Defaults to '#FFFFFF'.
* @return string
*/
function sinatra_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
return sinatra_is_light_color( $color ) ? $dark : $light;
}
if ( ! function_exists( 'sinatra_get_prop' ) ) :
/**
* Get a specific property of an array without needing to check if that property exists.
*
* Provide a default value if you want to return a specific value if the property is not set.
*
* @since 1.0.0
*
* @param array $array Array from which the property's value should be retrieved.
* @param string $prop Name of the property to be retrieved.
* @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null.
*
* @return null|string|mixed The value
*/
function sinatra_get_prop( $array, $prop, $default = null ) {
if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) {
return $default;
}
if ( isset( $array[ $prop ] ) ) {
$value = $array[ $prop ];
} else {
$value = '';
}
return empty( $value ) && null !== $default ? $default : $value;
}
endif;
/**
* Print objects to error log.
*
* @since 1.0.0
* @param string $object Object to be printed.
*/
function sinatra_log( $object ) {
// phpcs:disable
ob_start();
print_r( $object );
error_log( ob_get_clean() );
// phpcs:enable
}
/**
* Returns blog page URL.
*
* @since 1.0.0
* @return String, current page URL.
*/
function sinatra_get_blog_url() {
$blog_url = '';
// If front page is set to display a static page, get the URL of the posts page.
if ( 'page' === get_option( 'show_on_front' ) ) {
$page_for_posts = get_option( 'page_for_posts' );
if ( $page_for_posts ) {
$blog_url = get_permalink( $page_for_posts );
}
} else {
// The front page IS the posts page. Get its URL.
$blog_url = home_url( '/' );
}
return apply_filters( 'sinatra_site_url', $blog_url );
}
/**
* Returns array of default values for Design Options field.
*
* @since 1.0.0
* @param array $options Default options.
* @return array $defaults array of default values.
*/
function sinatra_design_options_defaults( $options = array() ) {
$defaults = array();
// Background options.
if ( isset( $options['background'] ) ) {
// Default background type.
if ( isset( $options['background']['background-type'] ) && in_array( $options['background']['background-type'], array( 'color', 'image', 'gradient' ), true ) ) {
$defaults['background-type'] = $options['background']['background-type'];
} else {
$defaults['background-type'] = 'color';
}
// Background color defaults.
if ( isset( $options['background']['color'] ) ) {
$defaults += wp_parse_args(
(array) $options['background']['color'],
array(
'background-color' => '',
)
);
}
// Background image defaults.
if ( isset( $options['background']['image'] ) ) {
$defaults += wp_parse_args(
(array) $options['background']['image'],
array(
'background-image' => '',
'background-repeat' => 'no-repeat',
'background-position-x' => '50',
'background-position-y' => '50',
'background-size' => 'cover',
'background-attachment' => 'inherit',
'background-image-id' => '',
'background-color-overlay' => 'rgba(0,0,0,0.5)',
)
);
}
// Background gradient defaults.
if ( isset( $options['background']['gradient'] ) ) {
$defaults += wp_parse_args(
(array) $options['background']['gradient'],
array(
'gradient-color-1' => '#16222A',
'gradient-color-1-location' => '0',
'gradient-color-2' => '#3A6073',
'gradient-color-2-location' => '100',
'gradient-type' => 'linear',
'gradient-linear-angle' => '45',
'gradient-position' => 'center center',
)
);
}
}
// Border default.
if ( isset( $options['border'] ) ) {
$defaults += wp_parse_args(
(array) $options['border'],
array(
'border-left-width' => '',
'border-top-width' => '',
'border-right-width' => '',
'border-bottom-width' => '',
'border-color' => '',
'style' => 'solid',
'separator-color' => '',
)
);
}
// Color default.
if ( isset( $options['color'] ) ) {
$defaults += wp_parse_args(
(array) $options['color'],
array(
'text-color' => '',
'link-color' => '',
'link-hover-color' => '',
)
);
}
return apply_filters( 'sinatra_design_options_defaults', $defaults, $options );
}
/**
* Returns array of default values for Typography field.
*
* @since 1.0.0
* @param array $options Default options.
* @return array $defaults array of default values.
*/
function sinatra_typography_defaults( $options = array() ) {
$defaults = apply_filters(
'sinatra_typography_defaults',
array(
'font-family' => 'inherit',
'font-subsets' => array(),
'font-weight' => '400',
'font-style' => 'inherit',
'text-transform' => 'inherit',
'text-decoration' => 'inherit',
'font-size-desktop' => '',
'font-size-tablet' => '',
'font-size-mobile' => '',
'font-size-unit' => 'px',
'letter-spacing' => '0',
'letter-spacing-unit' => 'px',
'line-height-desktop' => '',
'line-height-tablet' => '',
'line-height-mobile' => '',
'line-height-unit' => '',
)
);
$options = wp_parse_args( $options, $defaults );
return $options;
}
if ( ! function_exists( 'sinatra_enable_page_builder_compatibility' ) ) :
/**
* Allow filter to enable/disable page builder compatibility.
*
* @since 1.0.0
*
* @return bool True - If the page builder compatibility is enabled. False - IF the page builder compatibility is disabled.
*/
function sinatra_enable_page_builder_compatibility() {
return apply_filters( 'sinatra_enable_page_builder_compatibility', true );
}
endif;
/**
* Insert into array before specified key.
*
* @since 1.0.0
* @param array $array Array to be modified.
* @param array $pairs Array of key => value pairs to insert.
* @param mixed $key Key of $array to insert before or after.
* @param string $position Before or after $key.
* @return array $result Array with inserted $new value.
*/
function sinatra_array_insert( $array, $pairs, $key, $position = 'after' ) {
$key_pos = array_search( $key, array_keys( $array ), true );
if ( 'after' === $position ) {
$key_pos++;
}
if ( false !== $key_pos ) {
$result = array_slice( $array, 0, $key_pos );
$result = array_merge( $result, $pairs );
$result = array_merge( $result, array_slice( $array, $key_pos ) );
} else {
$result = array_merge( $array, $pairs );
}
return $result;
}
/**
* Get background color based on site layout.
*
* @since 1.0.0
* @return string Background color.
*/
function sinatra_get_background_color() {
$site_layout = sinatra_get_site_layout();
if ( in_array( $site_layout, array( 'boxed', 'boxed-separated' ), true ) ) {
$background_color = sinatra_option( 'boxed_content_background_color' );
} else {
$background_color = '#' . get_background_color();
}
return $background_color;
}
/**
* Check if a section is disabled.
*
* @since 1.1.0
*
* @param array $disabled_on Array of pages where the section is disabled.
* @param int $post_id Current page ID.
* @return bool Section is displayed.
*/
function sinatra_is_section_disabled( $disabled_on = array(), $post_id = 0 ) {
$disabled = false;
if ( is_front_page() && in_array( 'home', $disabled_on, true ) ) {
$disabled = true;
} elseif ( is_home() && in_array( 'posts_page', $disabled_on, true ) ) {
$disabled = true;
} elseif ( is_search() && in_array( 'search', $disabled_on, true ) ) {
$disabled = true;
} elseif ( is_archive() && in_array( 'archive', $disabled_on, true ) ) {
$disabled = true;
} elseif ( is_404() && in_array( '404', $disabled_on, true ) ) {
$disabled = true;
} elseif ( is_singular() || ! empty( $post_id ) ) {
if ( empty( $post_id ) ) {
$post_id = sinatra_get_the_id();
}
if ( in_array( get_post_type( $post_id ), $disabled_on, true ) ) {
$disabled = true;
}
}
return $disabled;
}
/**
* Get all the registered image sizes along with their dimensions.
*
* @since 1.1.0
* @return array $image_sizes The image sizes
*/
function sinatra_get_image_sizes() {
global $_wp_additional_image_sizes;
$default_image_sizes = get_intermediate_image_sizes();
foreach ( $default_image_sizes as $size ) {
$image_sizes[ $size ]['width'] = intval( get_option( "{$size}_size_w" ) );
$image_sizes[ $size ]['height'] = intval( get_option( "{$size}_size_h" ) );
$image_sizes[ $size ]['crop'] = get_option( "{$size}_crop" ) ? get_option( "{$size}_crop" ) : false;
}
if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) {
$image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes );
}
$image_sizes['full'] = array(
'width' => '',
'height' => '',
'crop' => '',
);
return $image_sizes;
}
compatibility/back-compat.php 0000644 00000005331 15123153670 0012314 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Prevent switching to Highend X on old versions of WordPress.
*
* Switches to the default theme.
*
* @since 1.0.0
*/
function sinatra_switch_theme() {
switch_theme( WP_DEFAULT_THEME );
unset( $_GET['activated'] ); // phpcs:ignore
add_action( 'admin_notices', 'sinatra_upgrade_notice' );
}
add_action( 'after_switch_theme', 'sinatra_switch_theme' );
/**
* Adds a message for unsuccessful theme switch.
*
* Prints an update nag after an unsuccessful attempt to switch to
* Sinatra on WordPress versions prior to 4.7.
*
* @since 1.0.0
* @global string $wp_version WordPress version.
*/
function sinatra_upgrade_notice() {
/* translators: %s WordPress version */
$message = sprintf( esc_html__( 'Sinatra theme requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'sinatra' ), $GLOBALS['wp_version'] );
printf( '', esc_html( $message ) );
}
/**
* Prevents the Customizer from being loaded on WordPress versions prior to 4.7.
*
* @since 1.0.0
* @global string $wp_version WordPress version.
*/
function sinatra_customize_prevent() {
/* translators: %s WordPress version */
$message = sprintf( esc_html__( 'Sinatra theme requires at least WordPress version 4.7. You are running version %s. Please upgrade your WordPress and try again.', 'sinatra' ), $GLOBALS['wp_version'] );
wp_die( esc_html( $message ), '', array( 'back_link' => true ) );
}
add_action( 'load-customize.php', 'sinatra_customize_prevent' );
/**
* Prevents the Theme Preview from being loaded on WordPress versions prior to 4.7.
*
* @since 1.0.0
* @global string $wp_version WordPress version.
*/
function sinatra_preview_prevent() {
if ( isset( $_GET['preview'] ) ) { // phpcs:ignore
/* translators: %s WordPress version */
$message = sprintf( esc_html__( 'Sinatra theme requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'sinatra' ), $GLOBALS['wp_version'] );
wp_die( esc_html( $message ) );
}
}
add_action( 'template_redirect', 'sinatra_preview_prevent' );
if ( ! function_exists( 'wp_body_open' ) ) {
/**
* Backward compatibility for wp_body_open hook.
*
* @since 1.0.0
*/
function wp_body_open() { // phpcs:ignore
do_action( 'wp_body_open' ); // phpcs:ignore
}
}
compatibility/class-sinatra-beaver-themer.php 0000644 00000012216 15123153670 0015423 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Return if Beaver Themer not active.
if ( ! class_exists( 'FLThemeBuilderLoader' ) || ! class_exists( 'FLThemeBuilderLayoutData' ) ) {
return;
}
// PHP 5.3+ is required.
if ( ! version_compare( PHP_VERSION, '5.3', '>=' ) ) {
return;
}
if ( ! class_exists( 'Sinatra_Beaver_Themer' ) ) :
/**
* Beaver Themer compatibility.
*/
class Sinatra_Beaver_Themer {
/**
* Singleton instance of the class.
*
* @var object
*/
private static $instance;
/**
* Instance.
*
* @since 1.0.0
* @return Sinatra_Beaver_Themer
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Sinatra_Beaver_Themer ) ) {
self::$instance = new Sinatra_Beaver_Themer();
}
return self::$instance;
}
/**
* Primary class constructor.
*
* @since 1.0.0
* @return void
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'add_theme_support' ) );
add_action( 'wp', array( $this, 'header_footer_render' ) );
add_action( 'wp', array( $this, 'page_header_render' ) );
add_filter( 'fl_theme_builder_part_hooks', array( $this, 'register_part_hooks' ) );
}
/**
* Add theme support
*
* @since 1.0.0
*/
public function add_theme_support() {
add_theme_support( 'fl-theme-builder-headers' );
add_theme_support( 'fl-theme-builder-footers' );
add_theme_support( 'fl-theme-builder-parts' );
}
/**
* Update header/footer with Beaver template
*
* @since 1.0.0
*/
public function header_footer_render() {
// Get the header ID.
$header_ids = FLThemeBuilderLayoutData::get_current_page_header_ids();
// If we have a header, remove the theme header and hook in Theme Builder's.
if ( ! empty( $header_ids ) ) {
// Remove Top Bar.
remove_action( 'sinatra_header', 'sinatra_topbar_output', 10 );
// Remove Main Header.
remove_action( 'sinatra_header', 'sinatra_header_output', 20 );
// Replacement header.
add_action( 'sinatra_header', 'FLThemeBuilderLayoutRenderer::render_header' );
}
// Get the footer ID.
$footer_ids = FLThemeBuilderLayoutData::get_current_page_footer_ids();
// If we have a footer, remove the theme footer and hook in Theme Builder's.
if ( ! empty( $footer_ids ) ) {
// Remove Main Footer.
remove_action( 'sinatra_footer', 'sinatra_footer_output', 20 );
// Remove Copyright Bar.
remove_action( 'sinatra_footer', 'sinatra_copyright_bar_output', 30 );
// Replacement footer.
add_action( 'sinatra_footer', 'FLThemeBuilderLayoutRenderer::render_footer' );
}
}
/**
* Remove page header if using Beaver Themer.
*
* @since 1.0.0
*/
public function page_header_render() {
// Get the page ID.
$page_ids = FLThemeBuilderLayoutData::get_current_page_content_ids();
// If we have a content layout, remove the theme page header.
if ( ! empty( $page_ids ) ) {
remove_action( 'sinatra_page_header', 'sinatra_page_header_template' );
}
}
/**
* Register hooks
*
* @since 1.0.0
*/
public function register_part_hooks() {
return array(
array(
'label' => 'Header',
'hooks' => array(
'sinatra_before_masthead' => esc_html__( 'Before Header', 'sinatra' ),
'sinatra_after_masthead' => esc_html__( 'After Header', 'sinatra' ),
),
),
array(
'label' => 'Main',
'hooks' => array(
'sinatra_before_main' => esc_html__( 'Before Main', 'sinatra' ),
'sinatra_after_main' => esc_html__( 'After Main', 'sinatra' ),
),
),
array(
'label' => 'Content',
'hooks' => array(
'sinatra_before_page_content' => esc_html__( 'Before Content', 'sinatra' ),
'sinatra_after_page_content' => esc_html__( 'After Content', 'sinatra' ),
),
),
array(
'label' => 'Footer',
'hooks' => array(
'sinatra_before_colophon' => esc_html__( 'Before Footer', 'sinatra' ),
'sinatra_after_colophon' => esc_html__( 'After Footer', 'sinatra' ),
),
),
array(
'label' => 'Sidebar',
'hooks' => array(
'sinatra_before_sidebar' => esc_html__( 'Before Sidebar', 'sinatra' ),
'sinatra_after_sidebar' => esc_html__( 'After Sidebar', 'sinatra' ),
),
),
array(
'label' => 'Singular',
'hooks' => array(
'sinatra_before_singular' => __( 'Before Singular', 'sinatra' ),
'sinatra_after_singular' => __( 'After Singular', 'sinatra' ),
'sinatra_before_comments' => __( 'Before Comments', 'sinatra' ),
'sinatra_after_comments' => __( 'After Comments', 'sinatra' ),
'sinatra_before_single_content' => __( 'Before Single Content', 'sinatra' ),
'sinatra_after_single_content' => __( 'After Single Content', 'sinatra' ),
),
),
);
}
}
endif;
/**
* Returns the one Sinatra_Beaver_Themer instance.
*/
function sinatra_beaver_themer() {
return Sinatra_Beaver_Themer::instance();
}
sinatra_beaver_themer();
compatibility/class-sinatra-elementor-pro.php 0000644 00000011021 15123153670 0015456 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Return if Elementor not active.
if ( ! class_exists( '\Elementor\Plugin' ) || ! class_exists( 'ElementorPro\Modules\ThemeBuilder\Module' ) ) {
return;
}
// PHP 5.3+ is required.
if ( ! version_compare( PHP_VERSION, '5.3', '>=' ) ) {
return;
}
if ( ! class_exists( 'Sinatra_Elementor_Pro' ) ) :
/**
* Elementor compatibility.
*/
class Sinatra_Elementor_Pro {
/**
* Singleton instance of the class.
*
* @var object
*/
private static $instance;
/**
* Elementor location manager
*
* @var object
*/
public $elementor_location_manager;
/**
* Instance.
*
* @since 1.0.0
* @return Sinatra_Elementor_Pro
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Sinatra_Elementor_Pro ) ) {
self::$instance = new Sinatra_Elementor_Pro();
}
return self::$instance;
}
/**
* Primary class constructor.
*
* @since 1.0.0
* @return void
*/
public function __construct() {
// Register theme locations.
add_action( 'elementor/theme/register_locations', array( $this, 'register_locations' ) );
// Override templates.
add_action( 'sinatra_header', array( $this, 'do_header' ), 0 );
add_action( 'sinatra_footer', array( $this, 'do_footer' ), 0 );
add_action( 'sinatra_content_404', array( $this, 'do_content_none' ), 0 );
add_action( 'sinatra_content_single', array( $this, 'do_content_single_post' ), 0 );
add_action( 'sinatra_content_page', array( $this, 'do_content_single_page' ), 0 );
add_action( 'sinatra_content_archive', array( $this, 'do_archive' ), 0 );
}
/**
* Register Theme Location for Elementor.
*
* @param object $manager Elementor object.
* @since 1.0.0
* @return void
*/
public function register_locations( $manager ) {
$manager->register_all_core_location();
$this->elementor_location_manager = \ElementorPro\Modules\ThemeBuilder\Module::instance()->get_locations_manager(); // phpcs:ignore
}
/**
* Override Header.
*
* @since 1.0.0
* @return void
*/
public function do_header() {
$did_location = $this->elementor_location_manager->do_location( 'header' );
if ( $did_location ) {
remove_action( 'sinatra_header', 'sinatra_topbar_output', 10 );
remove_action( 'sinatra_header', 'sinatra_header_output', 20 );
}
}
/**
* Override Footer.
*
* @since 1.0.0
* @return void
*/
public function do_footer() {
$did_location = $this->elementor_location_manager->do_location( 'footer' );
if ( $did_location ) {
remove_action( 'sinatra_footer', 'sinatra_footer_output', 20 );
remove_action( 'sinatra_footer', 'sinatra_copyright_bar_output', 30 );
}
}
/**
* Override Footer.
*
* @since 1.0.0
* @return void
*/
public function do_content_none() {
if ( ! is_404() ) {
return;
}
$did_location = $this->elementor_location_manager->do_location( 'single' );
if ( $did_location ) {
remove_action( 'sinatra_content_404', 'sinatra_404_page_content' );
}
}
/**
* Override Single Post.
*
* @since 1.0.0
* @return void
*/
public function do_content_single_post() {
$did_location = $this->elementor_location_manager->do_location( 'single' );
if ( $did_location ) {
remove_action( 'sinatra_content_single', 'sinatra_content_single' );
remove_action( 'sinatra_after_singular', 'sinatra_output_comments' );
}
}
/**
* Override Single Page.
*
* @since 1.0.0
* @return void
*/
public function do_content_single_page() {
$did_location = $this->elementor_location_manager->do_location( 'single' );
if ( $did_location ) {
remove_action( 'sinatra_content_page', 'sinatra_content_page' );
remove_action( 'sinatra_after_singular', 'sinatra_output_comments' );
}
}
/**
* Override Archive.
*
* @since 1.0.0
* @return void
*/
public function do_archive() {
$did_location = $this->elementor_location_manager->do_location( 'archive' );
if ( $did_location ) {
remove_action( 'sinatra_before_content', 'sinatra_archive_info' );
remove_action( 'sinatra_content_archive', 'sinatra_content' );
}
}
}
endif;
/**
* Returns the one Sinatra_Elementor_Pro instance.
*/
function sinatra_elementor_pro() {
return Sinatra_Elementor_Pro::instance();
}
sinatra_elementor_pro();
compatibility/class-sinatra-elementor.php 0000644 00000010670 15123153670 0014671 0 ustar 00
* @since 1.0.0
*/
namespace Elementor; // phpcs:ignore
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Return if Elementor not active.
if ( ! class_exists( '\Elementor\Plugin' ) ) {
return;
}
if ( ! class_exists( 'Sinatra_Elementor' ) ) :
/**
* Elementor compatibility.
*/
class Sinatra_Elementor {
/**
* Singleton instance of the class.
*
* @var object
*/
private static $instance;
/**
* Instance.
*
* @since 1.0.0
* @return Sinatra_Elementor
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Sinatra_Elementor ) ) {
self::$instance = new Sinatra_Elementor();
}
return self::$instance;
}
/**
* Primary class constructor.
*
* @since 1.0.0
* @return void
*/
public function __construct() {
// Enqueue Elementor editor styles.
add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_editor_style' ) );
// Setup postdata for Elementor pages.
add_action( 'wp', array( $this, 'setup_postdata' ), 1 );
add_action( 'elementor/preview/init', array( $this, 'setup_postdata' ), 5 );
// Enqueue additional Elementor styles.
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_additional' ) );
}
/**
* Editor stylesheet.
*
* @since 1.0.0
*/
public function enqueue_editor_style() {
// Script debug.
$sinatra_dir = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'dev/' : '';
$sinatra_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_style(
'sinatra-elementor-editor',
SINATRA_THEME_URI . '/assets/css/compatibility/elementor-editor-style' . $sinatra_suffix . '.css',
false,
SINATRA_THEME_VERSION,
'all'
);
}
/**
* Setup default postdata for Elementor pages.
*
* @since 1.0.0
*
* @return void
*/
public function setup_postdata() {
// Page builder compatibility disabled.
if ( ! sinatra_enable_page_builder_compatibility() ) {
return;
}
// Skip posts.
if ( 'post' === get_post_type() ) {
return;
}
// Don't modify postdata if we are not on Elementor's edit page.
if ( ! $this->is_elementor_editor() ) {
return;
}
global $post;
$id = sinatra_get_the_id();
$setup = get_post_meta( $id, '_sinatra_page_builder_setup', true );
if ( isset( $post ) && empty( $setup ) && ( is_admin() || is_singular() ) && empty( $post->post_content ) && $this->is_built_with_elementor( $id ) ) {
update_post_meta( $id, '_sinatra_page_builder_setup', true );
update_post_meta( $id, 'sinatra_disable_page_title', true );
update_post_meta( $id, 'sinatra_disable_breadcrumbs', true );
update_post_meta( $id, 'sinatra_disable_thumbnail', true );
update_post_meta( $id, 'sinatra_sidebar_position', 'no-sidebar' );
update_post_meta( $id, '_wp_page_template', 'page-templates/template-sinatra-fullwidth.php' );
}
}
/**
* Additional Elementor styles.
*
* @since 1.0.0
*/
public function enqueue_additional() {
// Script debug.
$sinatra_dir = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'dev/' : '';
$sinatra_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
// Enqueue theme stylesheet.
wp_enqueue_style(
'sinatra-elementor',
SINATRA_THEME_URI . '/assets/css/compatibility/elementor' . $sinatra_suffix . '.css',
false,
SINATRA_THEME_VERSION,
'all'
);
}
/**
* Check if page is built with elementor.
*
* @param int $id Post/Page Id.
* @since 1.0.0
*
* @return boolean
*/
public function is_built_with_elementor( $id ) {
if ( version_compare( ELEMENTOR_VERSION, '1.5.0', '<' ) ) {
return ( 'builder' === Plugin::$instance->db->get_edit_mode( $id ) );
} else {
return Plugin::$instance->db->is_built_with_elementor( $id );
}
}
/**
* Check if Elementor Editor is loaded.
*
* @since 1.0.0
*
* @return boolean Elementor editor is loaded.
*/
private function is_elementor_editor() {
return ( isset( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] ) || isset( $_REQUEST['elementor-preview'] ); // phpcs:ignore
}
}
endif;
/**
* Returns the one Sinatra_Elementor instance.
*/
function sinatra_elementor() {
return Sinatra_Elementor::instance();
}
sinatra_elementor();
compatibility/class-sinatra-endurance.php 0000644 00000036307 15123153670 0014650 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( 'BlueHost' !== get_option( 'mm_brand' ) ) {
return;
}
if ( ! class_exists( 'Sinatra_Endurance' ) ) :
/**
* Sinatra integration for Bluehost
*/
class Sinatra_Endurance {
/**
* Singleton instance of the class.
*
* @var object
*/
private static $instance;
/**
* Main Sinatra_Endurance Instance.
*
* @since 1.0.0
* @return Sinatra_Endurance
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Sinatra_Endurance ) ) {
self::$instance = new Sinatra_Endurance();
}
return self::$instance;
}
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct() {
/**
* Registers our custom options in Customizer.
*/
add_action( 'customize_register', array( $this, 'register_options' ), 11 );
/**
* Add WP Pointers.
*/
add_action( 'admin_enqueue_scripts', array( $this, 'add_pointers' ) );
/**
* Script to handle WP Pointers interaction.
*/
add_action( 'admin_print_footer_scripts', array( $this, 'add_pointers_script' ) );
/**
* Ajax handler to restart the Customizer Tour.
*/
add_action( 'wp_ajax_sinatra_start_customizer_tour', array( $this, 'start_customizer_tour' ) );
/**
* Modify recommended plugins.
*/
add_filter( 'sinatra_recommended_plugins', array( $this, 'recommended_plugins' ) );
}
/**
* Registers custom options in Customizer.
*
* @since 1.0.0
* @param WP_Customize_Manager $customizer Instance of WP_Customize_Manager class.
*/
public function register_options( $customizer ) {
// Help section in Customizer.
if ( class_exists( 'Sinatra_Customizer_Control_Button' ) ) {
$customizer->add_section(
'sinatra_section_help',
array(
'title' => esc_html__( 'Help', 'sinatra' ),
'priority' => 999,
)
);
// Reset tour.
$customizer->add_setting(
'sinatra_help_reset_tour',
array(
'sanitize_callback' => 'sinatra_no_sanitize',
)
);
$customizer->add_control(
new Sinatra_Customizer_Control_Button(
$customizer,
'sinatra_help_reset_tour',
array(
'label' => esc_html__( 'Take a Tour', 'sinatra' ),
'section' => 'sinatra_section_help',
'ajax_action' => 'sinatra_start_customizer_tour',
'button_text' => esc_html__( 'Start Tour', 'sinatra' ),
'settings' => 'sinatra_help_reset_tour',
'priority' => 10,
)
)
);
// Sinatra docs.
$customizer->add_setting(
'sinatra_help_sinatra_docs',
array(
'sanitize_callback' => 'sinatra_no_sanitize',
)
);
$customizer->add_control(
new Sinatra_Customizer_Control_Button(
$customizer,
'sinatra_help_sinatra_docs',
array(
'label' => esc_html__( 'Sinatra Theme Guide', 'sinatra' ),
'section' => 'sinatra_section_help',
'button_text' => esc_html__( 'Help Articles', 'sinatra' ),
'button_url' => 'https://sinatrawp.com/docs/',
'settings' => 'sinatra_help_sinatra_docs',
'priority' => 20,
)
)
);
// Customizer docs.
$customizer->add_setting(
'sinatra_help_customizer_docs',
array(
'sanitize_callback' => 'sinatra_no_sanitize',
)
);
$customizer->add_control(
new Sinatra_Customizer_Control_Button(
$customizer,
'sinatra_help_customizer_docs',
array(
'label' => esc_html__( 'WordPress Customizer Tutorial', 'sinatra' ),
'section' => 'sinatra_section_help',
'button_text' => esc_html__( 'Customizer Guide', 'sinatra' ),
'button_url' => 'https://sinatrawp.com/docs/the-ultimate-guide-to-the-wordpress-customizer/',
'settings' => 'sinatra_help_customizer_docs',
'priority' => 30,
)
)
);
}
}
/**
* Create pointers for current screen.
*
* @since 1.0.0
*/
public function add_pointers() {
$current_screen = get_current_screen();
if ( ! $current_screen ) {
return;
}
$pointers = array();
// Get all pointers.
switch ( $current_screen->id ) {
case 'customize':
$pointers = $this->customizer_pointers();
break;
default:
break;
}
// Check if any pointers are to be displayed.
if ( empty( $pointers ) ) {
return;
}
// Filter out dismissed pointers.
$dismissed = get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true );
$dismissed = explode( ',', (string) $dismissed );
foreach ( $pointers as $pointer_id => $pointer ) {
if ( in_array( $pointer_id, $dismissed, true ) ) {
$this->pointers = array();
break;
}
if ( empty( $pointer ) || empty( $pointer_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) {
$this->pointers = array();
break;
}
$this->pointers[ $pointer_id ] = $pointer;
}
// Check if any pointers are to be displayed.
if ( empty( $this->pointers ) ) {
return;
}
// Enqueue pointer script.
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
}
/**
* Customizer pointers.
*
* @since 1.0.0
*/
public function customizer_pointers() {
$pointers = array(
'sinatra-pointer-01' => array(
'id' => 'sinatra-pointer-01',
'target' => '#customize-info',
'next' => 'sinatra-pointer-02',
'options' => array(
'content' => '
' . esc_html__( 'Welcome to your WordPress Site! Let us give you a quick overview to help you customize your website’s design. Or, come back to this tour at any time in the “Help” tab.', 'sinatra' ) . '
',
'position' => array(
'edge' => 'left',
'align' => 'top',
),
),
'focus' => array(
'type' => 'root',
),
'arrow' => 'arrow-top',
),
'sinatra-pointer-02' => array(
'id' => 'sinatra-pointer-02',
'target' => '#accordion-section-themes',
'previous' => 'sinatra-pointer-01',
'next' => 'sinatra-pointer-03',
'options' => array(
'content' => '' . esc_html__( 'Your website design and theme', 'sinatra' ) . '
' .
'' . sprintf( wp_kses( 'To help you get building as fast as possible, we pre-installed our favorite theme, %3$sSinatra%4$s, but you can change this theme at any time. %1$sRead more about Sinatra.%2$s', sinatra_get_allowed_html_tags() ), '', '', '', '' ) . '
',
'position' => array(
'edge' => 'left',
'align' => 'middle',
),
),
'focus' => array(
'type' => 'root',
),
),
'sinatra-pointer-03' => array(
'id' => 'sinatra-pointer-03',
'target' => '#accordion-panel-sinatra_panel_general',
'previous' => 'sinatra-pointer-02',
'next' => 'sinatra-pointer-04',
'options' => array(
'content' => '' . esc_html__( 'Customize your design', 'sinatra' ) . '
' .
'' . esc_html__( 'Give your site a personalized look. Here you can change your site layout, colors, fonts and more.', 'sinatra' ) . '
',
'position' => array(
'edge' => 'left',
'align' => 'middle',
),
),
'focus' => array(
'type' => 'root',
),
),
'sinatra-pointer-04' => array(
'id' => 'sinatra-pointer-04',
'target' => '#accordion-panel-sinatra_panel_blog',
'previous' => 'sinatra-pointer-03',
'next' => 'sinatra-pointer-05',
'options' => array(
'content' => '' . esc_html__( 'Change your blog layout or location', 'sinatra' ) . '
' .
'' . esc_html__( 'Customize the look and feel of your blog and introduce yourself to your viewers, customers or the world.', 'sinatra' ) . '
',
'position' => array(
'edge' => 'left',
'align' => 'middle',
),
),
'focus' => array(
'type' => 'root',
),
),
'sinatra-pointer-05' => array(
'id' => 'sinatra-pointer-05',
'target' => '#customize-header-actions',
'previous' => 'sinatra-pointer-04',
'options' => array(
'content' => '' . esc_html__( 'Save, preview, publish or exit', 'sinatra' ) . '
' .
'' . esc_html__( 'Done for now? Save, preview, publish or schedule when you want to publish the latest edits to your site. Or, close the customizer to go to your WordPress dashboard to modify your website’s settings or preferences. ', 'sinatra' ) . '
',
'position' => array(
'edge' => 'top',
'align' => 'left',
),
),
'focus' => array(
'type' => 'root',
),
),
);
return $pointers;
}
/**
* Print JavaScript if pointers are available.
*
* @since 1.0.0
*/
public function add_pointers_script() {
if ( empty( $this->pointers ) ) {
return;
}
$pointers = wp_json_encode( $this->pointers );
// phpcs:disable
echo "
";
// phpcs:enable
}
/**
* AJAX handler to reset WP Pointers for the customizer tour.
*
* @since 1.0.0
*/
public function start_customizer_tour() {
// Security check.
check_ajax_referer( 'sinatra_customizer' );
$customizer_pointers = $this->customizer_pointers();
if ( ! empty( $customizer_pointers ) ) {
$dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
foreach ( $customizer_pointers as $pointer => $config ) {
$key = array_search( $pointer, $dismissed, true );
if ( false !== $key ) {
unset( $dismissed[ $key ] );
}
}
$dismissed = implode( ',', $dismissed );
update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed );
// Reload page and start the tour.
wp_send_json_success( array( 'reload' => true ) );
}
// Error.
wp_send_json_error();
}
/**
* Modify recommended plugins for Endurance users.
*
* @since 1.0.0
* @param Array $plugins Array of recommended plugins.
* @return Array Modified array of recommended plugins.
*/
public function recommended_plugins( $plugins ) {
if ( is_array( $plugins ) && ! empty( $plugins ) ) {
foreach ( $plugins as $slug => $plugin ) {
if ( isset( $plugin['endurance'] ) && false === $plugin['endurance'] ) {
unset( $plugins[ $slug ] );
}
}
}
return $plugins;
}
}
endif;
/**
* The function which returns the one Sinatra_Endurance instance.
*/
function sinatra_endurance() {
return Sinatra_Endurance::instance();
}
sinatra_endurance();
compatibility/class-sinatra-hfe.php 0000644 00000004235 15123153670 0013441 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Return if Elementor not active.
if ( ! class_exists( '\Elementor\Plugin' ) ) {
return;
}
// Return if HFE not active.
if ( ! class_exists( 'Header_Footer_Elementor' ) ) {
return false;
}
if ( ! class_exists( 'Sinatra_HFE' ) ) :
/**
* HFE compatibility.
*/
class Sinatra_HFE {
/**
* Singleton instance of the class.
*
* @var object
*/
private static $instance;
/**
* Instance.
*
* @since 1.0.0
* @return Sinatra_HFE
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Sinatra_HFE ) ) {
self::$instance = new Sinatra_HFE();
}
return self::$instance;
}
/**
* Primary class constructor.
*
* @since 1.0.0
* @return void
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'add_theme_support' ) );
add_action( 'sinatra_header', array( $this, 'do_header' ), 0 );
add_action( 'sinatra_footer', array( $this, 'do_footer' ), 0 );
}
/**
* Add theme support
*
* @since 1.0.0
*/
public function add_theme_support() {
add_theme_support( 'header-footer-elementor' );
}
/**
* Override Header
*
* @since 1.0.0
* @return void
*/
public function do_header() {
if ( ! hfe_header_enabled() ) {
return;
}
hfe_render_header();
remove_action( 'sinatra_header', 'sinatra_topbar_output', 10 );
remove_action( 'sinatra_header', 'sinatra_header_output', 20 );
}
/**
* Override Footer
*
* @since 1.0.0
* @return void
*/
public function do_footer() {
if ( ! hfe_footer_enabled() ) {
return;
}
hfe_render_footer();
remove_action( 'sinatra_footer', 'sinatra_footer_output', 20 );
remove_action( 'sinatra_footer', 'sinatra_copyright_bar_output', 30 );
}
}
endif;
/**
* Returns the one Sinatra_HFE instance.
*/
function sinatra_hfe() {
return Sinatra_HFE::instance();
}
sinatra_hfe();
compatibility/class-sinatra-jetpack.php 0000644 00000005222 15123153670 0014315 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Check if Jetpack is installed & activated.
if ( ! class_exists( 'Jetpack' ) ) {
return;
}
if ( ! class_exists( 'Sinatra_Jetpack' ) ) :
/**
* Jetpack compatibility class.
*/
class Sinatra_Jetpack {
/**
* Primary class constructor.
*
* @since 1.0.0
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'jetpack_supports' ) );
add_filter( 'infinite_scroll_credit', array( $this, 'tweak_credits_link' ) );
add_filter( 'infinite_scroll_js_settings', array( $this, 'filter_infinite_scroll_js_settings' ) );
}
/**
* Add Jetpack theme supports.
*
* @since 1.0.0
*/
public function jetpack_supports() {
/**
* Add theme support for Infinite Scroll.
*/
add_theme_support(
'infinite-scroll',
array(
'container' => 'content',
'render' => array( $this, 'infinite_scroll_render' ),
'footer' => 'page',
'posts_per_page' => get_option( 'posts_per_page' ),
'type' => 'click',
)
);
/**
* Add theme support for Responsive Videos.
*/
add_theme_support( 'jetpack-responsive-videos' );
/**
* Add theme support for geo-location.
*/
add_theme_support( 'jetpack-geo-location' );
}
/**
* Custom render function for Infinite Scroll.
*
* @since 1.0.0
*/
public function infinite_scroll_render() {
// WooCommerce products.
if ( function_exists( 'is_shop' ) && is_shop() || function_exists( 'is_product_taxonomy' ) && is_product_taxonomy() ) {
// Shop & category pages handled by default.
return;
} else {
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content/content', sinatra_get_article_feed_layout() );
endwhile;
}
}
/**
* Tweak footer credits bar link.
*
* @since 1.0.0
*/
public function tweak_credits_link() {
return '' . esc_html__( 'Proudly powered by WordPress', 'sinatra' ) . ' | Sinatra Theme';
}
/**
* Filter Jetpack infinite scroll JS settings.
*
* @since 1.0.0
* @param array $settings Infinite Scroll JS settings.
*/
public function filter_infinite_scroll_js_settings( $settings ) {
$settings['text'] = esc_html__( 'Load More', 'sinatra' );
return $settings;
}
}
endif;
new Sinatra_Jetpack();
compatibility/class-sinatra-wpforms.php 0000644 00000001574 15123153670 0014377 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Sinatra_WPForms' ) ) :
/**
* WPForms compatibility class.
*/
class Sinatra_WPForms {
/**
* Primary class constructor.
*
* @since 1.0.0
*/
public function __construct() {
add_action( 'activate_wpforms-lite/wpforms.php', array( $this, 'disable_redirect_on_activation' ), 20 );
// If WPForms is not activated then return.
if ( ! class_exists( 'WPForms' ) ) {
return;
}
}
/**
* Disable admin page redirect on plugin activation.
*
* @since 1.0.0
*/
public function disable_redirect_on_activation() {
delete_transient( 'wpforms_activation_redirect' );
}
}
endif;
new Sinatra_WPForms();
compatibility/socialsnap/class-sinatra-socialsnap.php 0000644 00000005242 15123153670 0017166 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Sinatra_SocialSnap' ) ) :
/**
* Social Snap compatibility class.
*/
class Sinatra_SocialSnap {
/**
* Primary class constructor.
*
* @since 1.0.0
*/
public function __construct() {
add_action( 'activate_socialsnap/socialsnap.php', array( $this, 'disable_redirect_on_activation' ), 20 );
// If Social Snap is not activated then return.
if ( ! class_exists( 'SocialSnap' ) ) {
return;
}
// Filter Customizer options.
add_filter( 'sinatra_customizer_options', array( $this, 'register_options' ), 20 );
// Set default Customizer values.
add_filter( 'sinatra_default_option_values', array( $this, 'default_customizer_values' ), 20 );
// Remove Social Snap Lite from recommended plugins.
add_filter( 'sinatra_recommended_plugins', array( $this, 'update_recommended_plugins' ) );
// Include helper functions.
require SINATRA_THEME_PATH . '/inc/compatibility/socialsnap/socialsnap-functions.php'; // phpcs:ignore
}
/**
* Disable admin page redirect on plugin activation.
*
* @since 1.0.0
*/
public static function disable_redirect_on_activation() {
delete_site_transient( 'socialsnap_activation_redirect' );
}
/**
* Filter options to include Social Snap.
*
* @since 1.1.0
* @param array $options Array of customizer options.
*/
public function register_options( $options ) {
$options['setting']['sinatra_single_post_meta_elements']['control']['choices']['shares'] = esc_html__( 'Shares', 'sinatra' );
$options['setting']['sinatra_blog_entry_meta_elements']['control']['choices']['shares'] = esc_html__( 'Shares', 'sinatra' );
return $options;
}
/**
* Add defaults for Social Snap options.
*
* @param array $defaults Array of default values.
* @return array Array of default values.
*/
public function default_customizer_values( $defaults ) {
$defaults['sinatra_single_post_meta_elements']['shares'] = false;
$defaults['sinatra_blog_entry_meta_elements']['shares'] = false;
return $defaults;
}
/**
* Removes Social Snap lite from recommended plugins if premium version of Social Snap is activated.
*
* @param array $plugins Plugins array.
* @return array
*/
public function update_recommended_plugins( $plugins ) {
// Check if pro version is installed.
if ( socialsnap()->pro ) {
unset( $plugins['socialsnap'] );
}
return $plugins;
}
}
endif;
new Sinatra_SocialSnap();
compatibility/socialsnap/socialsnap-functions.php 0000644 00000001452 15123153670 0016431 0 ustar 00
* @since 1.1.0
*/
if ( ! function_exists( 'sinatra_entry_meta_shares' ) ) :
/**
* Add share count information to entry meta.
*
* @since 1.1.0
*/
function sinatra_entry_meta_shares() {
$share_count = socialsnap_get_total_share_count();
// Icon.
$icon = sinatra_get_meta_icon( 'share', '' );
$output = sprintf(
'%3$s%1$s %2$s',
socialsnap_format_number( $share_count ),
esc_html( _n( 'Share', 'Shares', $share_count, 'sinatra' ) ),
wp_kses_post( $icon )
);
echo wp_kses_post( apply_filters( 'sinatra_entry_share_count', $output ) );
}
endif;
compatibility/woocommerce/class-sinatra-customizer-widget-cart.php 0000644 00000002000 15123153670 0021616 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Sinatra_Customizer_Widget_Cart' ) ) :
/**
* Sinatra Customizer widget class
*/
class Sinatra_Customizer_Widget_Cart extends Sinatra_Customizer_Widget {
/**
* Primary class constructor.
*
* @since 1.0.0
* @param array $args An array of the values for this widget.
*/
public function __construct( $args = array() ) {
parent::__construct( $args );
$this->name = esc_html__( 'Cart', 'sinatra' );
$this->description = esc_html__( 'Displays WooCommerce cart.', 'sinatra' );
$this->icon = 'dashicons dashicons-cart';
$this->type = 'cart';
}
/**
* Displays the form for this widget on the Widgets page of the WP Admin area.
*
* @since 1.0.0
* @return void
*/
public function form() {}
}
endif;
compatibility/woocommerce/class-sinatra-customizer-woocommerce.php 0000644 00000036020 15123153670 0021734 0 ustar 00
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Sinatra_Customizer_WooCommerce' ) ) :
/**
* Sinatra WooCommerce section in Customizer.
*/
class Sinatra_Customizer_WooCommerce {
/**
* Primary class constructor.
*
* @since 1.0.0
*/
public function __construct() {
// Registers our custom options in Customizer.
add_filter( 'sinatra_customizer_options', array( $this, 'register_options' ), 20 );
add_action( 'customize_register', array( $this, 'customizer_tweak' ), 20 );
// Add default values for WooCommerce options.
add_filter( 'sinatra_default_option_values', array( $this, 'default_customizer_values' ) );
// Add localized strings to script.
add_filter( 'sinatra_customizer_localized', array( $this, 'customizer_localized_strings' ) );
}
/**
* Add defaults for new WooCommerce customizer options.
*
* @param array $defaults Array of default values.
* @return array Array of default values.
*/
public function default_customizer_values( $defaults ) {
$defaults['sinatra_wc_product_gallery_lightbox'] = true;
$defaults['sinatra_wc_product_gallery_zoom'] = true;
$defaults['sinatra_shop_product_hover'] = 'none';
$defaults['sinatra_product_sale_badge'] = 'percentage';
$defaults['sinatra_product_sale_badge_text'] = esc_html__( 'Sale!', 'sinatra' );
$defaults['sinatra_wc_product_slider_arrows'] = true;
$defaults['sinatra_wc_product_gallery_style'] = 'default';
$defaults['sinatra_wc_product_sidebar_position'] = 'no-sidebar';
$defaults['sinatra_wc_sidebar_position'] = 'no-sidebar';
$defaults['sinatra_wc_upsell_products'] = true;
$defaults['sinatra_wc_upsells_columns'] = 4;
$defaults['sinatra_wc_upsells_rows'] = 1;
$defaults['sinatra_wc_related_products'] = true;
$defaults['sinatra_wc_related_columns'] = 4;
$defaults['sinatra_wc_related_rows'] = 1;
$defaults['sinatra_wc_cross_sell_products'] = true;
$defaults['sinatra_wc_cross_sell_rows'] = 1;
$defaults['sinatra_product_catalog_elements'] = array(
'category' => true,
'title' => true,
'ratings' => true,
'price' => true,
);
return $defaults;
}
/**
* Tweak Customizer.
*
* @since 1.0.0
* @param WP_Customize_Manager $customizer Instance of WP_Customize_Manager class.
*/
public function customizer_tweak( $customizer ) {
// Move WooCommerce panel.
$customizer->get_panel( 'woocommerce' )->priority = 10;
return $customizer;
}
/**
* Registers our custom options in Customizer.
*
* @since 1.0.0
* @param array $options Array of customizer options.
*/
public function register_options( $options ) {
// Shop image hover effect.
$options['setting']['sinatra_shop_product_hover'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_select',
'control' => array(
'type' => 'sinatra-select',
'section' => 'woocommerce_product_catalog',
'label' => esc_html__( 'Product image hover', 'sinatra' ),
'description' => esc_html__( 'Effect for product image on hover', 'sinatra' ),
'choices' => array(
'none' => esc_html__( 'No Effect', 'sinatra' ),
'image-swap' => esc_html__( 'Image Swap', 'sinatra' ),
),
),
);
// Sale badge.
$options['setting']['sinatra_product_sale_badge'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_select',
'control' => array(
'type' => 'sinatra-select',
'section' => 'woocommerce_product_catalog',
'label' => esc_html__( 'Product sale badge', 'sinatra' ),
'description' => esc_html__( 'Choose what to display on the product sale badge.', 'sinatra' ),
'choices' => array(
'hide' => esc_html__( 'Hide badge', 'sinatra' ),
'percentage' => esc_html__( 'Show percentage', 'sinatra' ),
'text' => esc_html__( 'Show text', 'sinatra' ),
),
),
);
// Sale badge text.
$options['setting']['sinatra_product_sale_badge_text'] = array(
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_text_field',
'control' => array(
'type' => 'sinatra-text',
'label' => esc_html__( 'Sale badge text', 'sinatra' ),
'description' => esc_html__( 'Add custom text for the product sale badge.', 'sinatra' ),
'placeholder' => esc_html__( 'Sale!', 'sinatra' ),
'section' => 'woocommerce_product_catalog',
'required' => array(
array(
'control' => 'sinatra_product_sale_badge',
'value' => 'text',
'operator' => '==',
),
),
),
);
// Catalog product elements.
$options['setting']['sinatra_product_catalog_elements'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_sortable',
'control' => array(
'type' => 'sinatra-sortable',
'section' => 'woocommerce_product_catalog',
'label' => esc_html__( 'Product details', 'sinatra' ),
'description' => esc_html__( 'Set order and visibility for product details.', 'sinatra' ),
'choices' => array(
'title' => esc_html__( 'Title', 'sinatra' ),
'ratings' => esc_html__( 'Ratings', 'sinatra' ),
'price' => esc_html__( 'Price', 'sinatra' ),
'category' => esc_html__( 'Category', 'sinatra' ),
),
),
);
// Section.
$options['section']['sinatra_woocommerce_single_product'] = array(
'title' => esc_html__( 'Single Product', 'sinatra' ),
'priority' => 50,
'panel' => 'woocommerce',
);
// Product Gallery Zoom.
$options['setting']['sinatra_wc_product_gallery_zoom'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_toggle',
'control' => array(
'type' => 'sinatra-toggle',
'label' => esc_html__( 'Gallery Zoom', 'sinatra' ),
'description' => esc_html__( 'Enable zoom effect when hovering product gallery.', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'space' => true,
),
);
// Product Gallery Lightbox.
$options['setting']['sinatra_wc_product_gallery_lightbox'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_toggle',
'control' => array(
'type' => 'sinatra-toggle',
'label' => esc_html__( 'Gallery Lightbox', 'sinatra' ),
'description' => esc_html__( 'Open product gallery images in lightbox.', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'space' => true,
),
);
// Product slider arrows.
$options['setting']['sinatra_wc_product_slider_arrows'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_toggle',
'control' => array(
'type' => 'sinatra-toggle',
'label' => esc_html__( 'Slider Arrows', 'sinatra' ),
'description' => esc_html__( 'Enable left and right arrows on product gallery slider.', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'space' => true,
),
);
// Related Products.
$options['setting']['sinatra_wc_related_products'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_toggle',
'control' => array(
'type' => 'sinatra-toggle',
'label' => esc_html__( 'Related Products', 'sinatra' ),
'description' => esc_html__( 'Display related products.', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'space' => true,
),
);
// Related product column count.
$options['setting']['sinatra_wc_related_columns'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_range',
'control' => array(
'type' => 'sinatra-range',
'label' => esc_html__( 'Related Products Columns', 'sinatra' ),
'description' => esc_html__( 'How many related products should be shown per row?', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'min' => 1,
'max' => 6,
'step' => 1,
'required' => array(
array(
'control' => 'sinatra_wc_related_products',
'value' => true,
'operator' => '==',
),
),
),
);
// Related product row count.
$options['setting']['sinatra_wc_related_rows'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_range',
'control' => array(
'type' => 'sinatra-range',
'label' => esc_html__( 'Related Products Rows', 'sinatra' ),
'description' => esc_html__( 'How many rows of related products should be shown?', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'min' => 1,
'max' => 5,
'step' => 1,
'required' => array(
array(
'control' => 'sinatra_wc_related_products',
'value' => true,
'operator' => '==',
),
),
),
);
// Up-Sell Products.
$options['setting']['sinatra_wc_upsell_products'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_toggle',
'control' => array(
'type' => 'sinatra-toggle',
'label' => esc_html__( 'Up-Sell Products', 'sinatra' ),
'description' => esc_html__( 'Display linked upsell products.', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'space' => true,
),
);
// Up-Sells column count.
$options['setting']['sinatra_wc_upsells_columns'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_range',
'control' => array(
'type' => 'sinatra-range',
'label' => esc_html__( 'Up-Sell Products Columns', 'sinatra' ),
'description' => esc_html__( 'How many up-sell products should be shown per row?', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'min' => 1,
'max' => 6,
'step' => 1,
'required' => array(
array(
'control' => 'sinatra_wc_upsell_products',
'value' => true,
'operator' => '==',
),
),
),
);
// Up-Sells rows count.
$options['setting']['sinatra_wc_upsells_rows'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_range',
'control' => array(
'type' => 'sinatra-range',
'label' => esc_html__( 'Up-Sell Products Rows', 'sinatra' ),
'description' => esc_html__( 'How many rows of up-sell products should be shown?', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'min' => 1,
'max' => 6,
'step' => 1,
'required' => array(
array(
'control' => 'sinatra_wc_upsell_products',
'value' => true,
'operator' => '==',
),
),
),
);
// Cross-Sell Products.
$options['setting']['sinatra_wc_cross_sell_products'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_toggle',
'control' => array(
'type' => 'sinatra-toggle',
'label' => esc_html__( 'Cross-Sell Products', 'sinatra' ),
'description' => esc_html__( 'Display linked cross-sell products on cart page.', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'space' => true,
),
);
// Cross-Sells rows count.
$options['setting']['sinatra_wc_cross_sell_rows'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_range',
'control' => array(
'type' => 'sinatra-range',
'label' => esc_html__( 'Cross-Sell Products Rows', 'sinatra' ),
'description' => esc_html__( 'How many rows of cross-sell products should be shown?', 'sinatra' ),
'section' => 'sinatra_woocommerce_single_product',
'min' => 1,
'max' => 6,
'step' => 1,
'required' => array(
array(
'control' => 'sinatra_wc_cross_sells_products',
'value' => true,
'operator' => '==',
),
),
),
);
$sidebar_options = array();
$sidebar_options['sinatra_wc_sidebar_position'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_select',
'control' => array(
'type' => 'sinatra-select',
'label' => esc_html__( 'WooCommerce', 'sinatra' ),
'description' => esc_html__( 'Choose default sidebar position for cart, checkout and catalog pages. You can change this setting per page via metabox settings.', 'sinatra' ),
'section' => 'sinatra_section_sidebar',
'choices' => array(
'default' => esc_html__( 'Default', 'sinatra' ),
'no-sidebar' => esc_html__( 'No Sidebar', 'sinatra' ),
'left-sidebar' => esc_html__( 'Left Sidebar', 'sinatra' ),
'right-sidebar' => esc_html__( 'Right Sidebar', 'sinatra' ),
),
),
);
$sidebar_options['sinatra_wc_product_sidebar_position'] = array(
'transport' => 'refresh',
'sanitize_callback' => 'sinatra_sanitize_select',
'control' => array(
'type' => 'sinatra-select',
'label' => esc_html__( 'WooCommerce - Single Product', 'sinatra' ),
'description' => esc_html__( 'Choose default sidebar position layout for product pages. You can change this setting per product via metabox settings.', 'sinatra' ),
'section' => 'sinatra_section_sidebar',
'choices' => array(
'default' => esc_html__( 'Default', 'sinatra' ),
'no-sidebar' => esc_html__( 'No Sidebar', 'sinatra' ),
'left-sidebar' => esc_html__( 'Left Sidebar', 'sinatra' ),
'right-sidebar' => esc_html__( 'Right Sidebar', 'sinatra' ),
),
),
);
$options['setting'] = sinatra_array_insert( $options['setting'], $sidebar_options, 'sinatra_archive_sidebar_position' );
return $options;
}
/**
* Add localize strings.
*
* @param array $strings Array of strings to be localized.
* @return array Modified string array.
*/
public function customizer_localized_strings( $strings ) {
// Preview a random single product for WooCommerce > Single Product section.
$products = get_posts(
array(
'post_type' => 'product',
'posts_per_page' => 1,
'orderby' => 'rand',
)
);
if ( count( $products ) ) {
$strings['preview_url_for_section']['sinatra_woocommerce_single_product'] = get_permalink( $products[0] );
}
return $strings;
}
}
endif;
new Sinatra_Customizer_WooCommerce();
compatibility/woocommerce/class-sinatra-woocommerce.php 0000644 00000116023 15123153670 0017534 0 ustar 00
* @since 1.0.0
*/
// If WooCommerce is not activated then return.
if ( ! sinatra_is_woocommerce_activated() ) {
add_action( 'activate_woocommerce/woocommerce.php', array( sinatra_dynamic_styles(), 'delete_dynamic_file' ) );
return;
}
/**
* Sinatra WooCommerce Compatibility.
*/
if ( ! class_exists( 'Sinatra_Woocommerce' ) ) :
/**
* Sinatra WooCommerce Compatibility
*
* @since 1.0.0
*/
class Sinatra_Woocommerce {
/**
* Singleton instance of the class.
*
* @since 1.0.0
* @var object
*/
private static $instance;
/**
* Main Instance.
*
* @since 1.0.0
* @return Sinatra_Woocommerce
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Sinatra_Woocommerce ) ) {
self::$instance = new Sinatra_Woocommerce();
self::$instance->includes();
self::$instance->actions();
}
return self::$instance;
}
/**
* Include files.
*
* @since 1.0.0
*/
private function includes() {
require SINATRA_THEME_PATH . '/inc/compatibility/woocommerce/woocommerce-functions.php'; // phpcs:ignore
require SINATRA_THEME_PATH . '/inc/compatibility/woocommerce/class-sinatra-customizer-woocommerce.php'; // phpcs:ignore
}
/**
* WooCommerce actions.
*
* @since 1.0.0
*/
private function actions() {
// Cart fragment.
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.3', '>=' ) ) {
add_filter( 'woocommerce_add_to_cart_fragments', array( $this, 'cart_widget_count_fragment' ) );
add_filter( 'woocommerce_add_to_cart_fragments', array( $this, 'cart_widget_dropdown_fragment' ) );
} else {
add_filter( 'add_to_cart_fragments', array( $this, 'cart_widget_count_fragment' ) );
add_filter( 'add_to_cart_fragments', array( $this, 'cart_widget_dropdown_fragment' ) );
}
// Frontend actions only.
if ( ! is_admin() ) {
add_action( 'wp', array( $this, 'product_catalog_elements' ) );
// Disable WooCommerce shop title.
add_filter( 'woocommerce_show_page_title', '__return_false' );
// Disable Sinatra page description.
add_filter( 'sinatra_page_header_description', array( $this, 'shop_remove_page_description' ) );
// Remove WooCommerce content wrappers.
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
// Remove WooCommerce breadcrumbs.
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
// Extend Sinatra breadcrumb trail.
add_filter( 'sinatra_breadcrumb_trail_items', array( $this, 'breadcrumbs' ), 20, 2 );
// Remove WooCommerce sidebar.
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar' );
add_action( 'sinatra_woocommerce_sidebar', 'woocommerce_get_sidebar' );
// Add our content wrappers.
add_action( 'woocommerce_before_main_content', array( $this, 'content_wrapper_start' ), 10 );
add_action( 'woocommerce_after_main_content', array( $this, 'content_wrapper_end' ), 10 );
// Replace WooCommerce pagination with Sinatra pagination.
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
add_action( 'woocommerce_after_shop_loop', 'sinatra_pagination' );
// Add back to shop button to Empty Cart.
add_action( 'woocommerce_cart_is_empty', 'sinatra_wc_empty_cart_button' );
// Add wrapper to result count and catalog ordering.
add_action( 'woocommerce_before_shop_loop', array( $this, 'result_wrapper_start' ), 19 );
add_action( 'woocommerce_before_shop_loop', array( $this, 'result_wrapper_end' ), 31 );
// Remove opening link tag.
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
// Add thumbnail wrapper.
add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'loop_product_thumb_wrap_start' ), 5 );
add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'loop_product_thumb_wrap_end' ), 15 );
// Add product link to thumnail.
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', 6 );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 13 );
// Add alternative image to display on hover.
add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'product_image_swap' ), 11 );
// Add to cart button to display on hover.
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 14 );
// Add wrapper to product meta details.
add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'loop_product_details_wrap_open' ), 19 );
add_action( 'woocommerce_after_shop_loop_item_title', array( $this, 'loop_product_details_wrap_end' ), 10 );
add_action( 'woocommerce_before_single_product_summary', array( $this, 'single_product_wrapper_start' ), 5 );
add_action( 'woocommerce_after_single_product_summary', array( $this, 'single_product_wrapper_end' ), 5 );
// Remove add to cart button from catalog pages.
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
// Percentage sale badge.
add_filter( 'woocommerce_sale_flash', 'sinatra_wc_add_percentage_to_sale_badge', 20, 3 );
// Out of stock product badge.
add_action( 'woocommerce_before_shop_loop_item_title', 'sinatra_wc_out_of_stock_badge', 10 );
add_action( 'woocommerce_before_single_product_summary', 'sinatra_wc_out_of_stock_badge', 10 );
// Additional classes for add to cart button.
add_filter( 'woocommerce_loop_add_to_cart_args', array( $this, 'loop_add_to_cart_args' ) );
// Heading for checkout page order.
add_action( 'woocommerce_review_order_before_payment', array( $this, 'review_order_heading' ) );
// Remove mini cart buttons and replace with ours.
remove_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_button_view_cart', 10 );
remove_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
add_action( 'woocommerce_widget_shopping_cart_buttons', 'sinatra_wc_widget_shopping_cart_buttons', 10 );
// Hide Yith wishlist - we show it in our page title anyway.
add_filter( 'yith_wcwl_wishlist_title', '__return_false', 20 );
// Remove checkout heading.
add_action( 'woocommerce_checkout_shipping', array( $this, 'checkout_shipping_heading' ), 9 );
add_filter( 'woocommerce_subcategory_count_html', 'sinatra_wc_cat_count_filter', 10, 2 );
add_filter( 'woocommerce_rating_filter_count', 'sinatra_wc_rating_count_filter', 10, 3 );
add_filter( 'woocommerce_layered_nav_count', 'sinatra_wc_layered_count_filter', 10, 3 );
// Upsell Products.
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', array( $this, 'woocommerce_upsell_display' ), 15 );
// Related Products.
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
add_action( 'woocommerce_after_single_product_summary', array( $this, 'woocommerce_related_products' ), 15 );
// Related products columns/count.
add_filter( 'woocommerce_output_related_products_args', array( $this, 'single_product_related_products_args' ) );
add_filter( 'woocommerce_single_product_carousel_options', array( $this, 'single_product_slider_options' ) );
// Cross-Sell products.
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
add_action( 'woocommerce_cart_collaterals', array( $this, 'woocommerce_cross_sell_display' ) );
// Product gallery thumbnail columns.
add_filter( 'woocommerce_product_thumbnails_columns', array( $this, 'product_thumbnails_columns' ) );
}
// Enqueue styles.
add_action( 'sinatra_enqueue_scripts', array( $this, 'enqueue' ) );
// Single product actions.
add_action( 'wp_head', array( $this, 'product_actions' ), 9 );
// Register WooCommerce sidebars.
add_action( 'widgets_init', array( $this, 'register_wc_sidebars' ) );
// Add correct sidebar.
add_filter( 'sinatra_sidebar_name', array( $this, 'set_sidebar' ) );
// Set sidebar position.
add_filter( 'sinatra_default_sidebar_position', array( $this, 'set_default_sidebar_position' ) );
// Remove item from cart.
add_action( 'wp_ajax_sinatra_remove_wc_cart_item', array( $this, 'remove_item_from_cart' ) );
add_action( 'wp_ajax_nopriv_sinatra_remove_wc_cart_item', array( $this, 'remove_item_from_cart' ) );
// Add theme supports.
add_action( 'after_setup_theme', array( $this, 'theme_supports' ), 20 );
// Add customizer cart widget.
add_filter( 'sinatra_customizer_widgets', array( $this, 'add_customizer_cart_widget' ) );
add_filter( 'sinatra_main_header_widgets', array( $this, 'add_cart_to_main_header_widgets' ) );
// Loads Cart Customizer widgets class.
add_action( 'customize_register', array( $this, 'load_customizer_widget' ), 20 );
// Handle admin redirects.
add_action( 'admin_init', array( $this, 'admin_redirects' ), 9 );
// Add dynamic CSS.
add_filter( 'sinatra_dynamic_styles', array( $this, 'dynamic_css' ), 5 );
// Update dynamic styles on deactivation.
add_action( 'deactivate_woocommerce/woocommerce.php', array( sinatra_dynamic_styles(), 'delete_dynamic_file' ) );
// Return Shop page ID.
add_filter( 'sinatra_get_the_id', array( $this, 'get_the_id' ) );
add_filter( 'woocommerce_product_related_products_heading', array( $this, 'related_products_heading' ) );
}
/**
* Declare WooCommerce support.
*
* @since 1.0.0
*/
public function theme_supports() {
// Declare WooCommerce compatibility.
add_theme_support(
'woocommerce',
array(
'gallery_thumbnail_image_width' => 150,
)
);
// Product Gallery Slider.
add_theme_support( 'wc-product-gallery-slider' );
// Product Gallery Zoom.
if ( sinatra_option( 'wc_product_gallery_zoom' ) ) {
add_theme_support( 'wc-product-gallery-zoom' );
}
// Product Gallery Lightbox.
if ( sinatra_option( 'wc_product_gallery_lightbox' ) ) {
add_theme_support( 'wc-product-gallery-lightbox' );
}
}
/**
* Enqueue WooCommerce styles.
*
* @since 1.0.0
*/
public function enqueue() {
// Script debug.
$sinatra_dir = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'dev/' : '';
$sinatra_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
// Enqueue WooCommerce compatibility stylesheet.
wp_enqueue_style(
'sinatra-woocommerce',
SINATRA_THEME_URI . '/assets/css/compatibility/woocommerce' . $sinatra_suffix . '.css',
false,
SINATRA_THEME_VERSION,
'all'
);
// Enqueue WooCommerce compatibility script.
wp_enqueue_script(
'sinatra-wc',
SINATRA_THEME_URI . '/assets/js/' . $sinatra_dir . 'sinatra-wc' . $sinatra_suffix . '.js',
array( 'jquery' ),
SINATRA_THEME_VERSION,
true
);
}
/**
* Add or remove actions depending on enabled product catalog elements.
*
* @return void
*/
public function product_catalog_elements() {
$elements = sinatra_option( 'product_catalog_elements' );
$hook = 'woocommerce_before_shop_loop_item_title';
$priority = 20;
if ( ! empty( $elements ) ) {
foreach ( $elements as $element => $enabled ) {
if ( 'title' === $element ) {
if ( ! $enabled ) {
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title' );
} else {
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_link_close' );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', $priority );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 4 );
}
$hook = 'woocommerce_after_shop_loop_item_title';
$priority = 5;
} elseif ( 'ratings' === $element ) {
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
if ( $enabled ) {
add_action( $hook, 'woocommerce_template_loop_rating', $priority );
$priority++;
}
} elseif ( 'price' === $element ) {
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
if ( $enabled ) {
add_action( $hook, 'woocommerce_template_loop_price', $priority );
$priority++;
}
} elseif ( 'category' === $element ) {
if ( $enabled ) {
add_action( $hook, array( $this, 'template_loop_category' ), $priority );
$priority++;
}
}
}
}
}
/**
* Print product categories in loop template.
*
* @return void
*/
public function template_loop_category() {
global $product;
$product_cats = wp_get_post_terms( $product->get_id(), 'product_cat' );
$cats = array();
if ( is_array( $product_cats ) && ! empty( $product_cats ) ) {
foreach ( $product_cats as $product_cat ) {
$cats[] = '' . esc_html( $product_cat->name ) . '';
}
}
echo '' . wp_kses_post( implode( ', ', $cats ) ) . '';
}
/**
* Add start wrapper to result count and catalog ordering.
*
* @since 1.0.0
* @return void
*/
public function result_wrapper_start() {
if ( ! woocommerce_products_will_display() ) {
return;
}
echo '';
}
/**
* Add end wrapper to result count and catalog ordering.
*
* @since 1.0.0
* @return void
*/
public function result_wrapper_end() {
if ( ! woocommerce_products_will_display() ) {
return;
}
echo '
';
}
/**
* Update cart count in Cart Widget via AJAX.
*
* @param array $fragments Fragments to refresh via AJAX.
* @return array Fragments to refresh via AJAX
* @since 1.0.0
*/
public function cart_widget_count_fragment( $fragments ) {
$fragments['.si-header-widget__cart a.si-cart'] = sinatra_wc_cart_icon( false );
return $fragments;
}
/**
* Update Cart Widget dropdown via AJAX.
*
* @param array $fragments Fragments to refresh via AJAX.
* @return array Fragments to refresh via AJAX
* @since 1.0.0
*/
public function cart_widget_dropdown_fragment( $fragments ) {
$fragments['.si-header-widget__cart .dropdown-item'] = sinatra_wc_cart_dropdown( false );
return $fragments;
}
/**
* Add start of WooCommerce content wrapper.
*
* @since 1.0.0
* @return void
*/
public function content_wrapper_start() {
?>
';
}
/**
* Add end of Single Product content wrapper.
*
* @since 1.0.0
* @return void
*/
public function single_product_wrapper_end() {
echo '