This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,180 @@
<?php
namespace Easy_Plugins\Table_Of_Contents;
use WP_Error;
/**
* Class Debug
*
* @package Easy_Plugins\Table_Of_Contents
*/
final class Debug extends WP_Error {
/**
* @since 2.0.13
* @var bool
*/
protected $display = false;
/**
* @since 2.0.13
* @var bool
*/
protected $enabled = false;
/**
* @var self
*/
private static $instance;
/**
* Debug constructor.
*
* @since 2.0.13
*
* @param string $code
* @param string $message
* @param string $data
*/
public function __construct( $code = '', $message = '', $data = '' ) {
parent::__construct( $code, $message, $data );
}
/**
* @since 2.0.14
*
* @param string $code
* @param string $message
* @param string $data
*
* @return Debug
*/
public static function log( $code = '', $message = '', $data = '' ) {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
self::$instance = new self( $code, $message, $data );
self::$instance->display = apply_filters(
'Easy_Plugins/Table_Of_Contents/Debug/Display',
defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY
);
self::$instance->enabled = apply_filters(
'Easy_Plugins/Table_Of_Contents/Debug/Enabled',
( defined( 'WP_DEBUG' ) && WP_DEBUG ) && current_user_can( 'manage_options' )
);
} else {
if ( ! empty( $code ) && ! empty( $message ) ) {
self::$instance->add( $code, $message, $data );
}
}
return self::$instance;
}
/**
* Adds an error or appends an additional message to an existing error.
*
* NOTE: Overrides WP_Error::add() to allow support of passing `false` as `$data`.
*
* @since 2.0.14
*
* @param string|int $code Error code.
* @param string $message Error message.
* @param mixed $data Optional. Error data.
*/
public function add( $code, $message, $data = null ) {
$this->errors[ $code ][] = $message;
if ( ! is_null( $data ) ) {
$this->add_data( $data, $code );
}
/**
* Fires when an error is added to a WP_Error object.
*
* @since 5.6.0
*
* @param string|int $code Error code.
* @param string $message Error message.
* @param mixed $data Error data. Might be empty.
* @param WP_Error $wp_error The WP_Error object.
*/
do_action( 'wp_error_added', $code, $message, $data, $this );
}
/**
* @since 2.0.13
*
* @param string $content
*
* @return string
*/
public function appendTo( $content = '' ) {
return $content . $this;
}
/**
* @since 2.0.13
*
* @return string
*/
public function dump() {
$dump = array();
foreach ( (array) $this->errors as $code => $messages ) {
$data = $this->get_error_data( $code );
$data = is_string( $data ) ? $data : '<code>' . var_export( $data, true ) . '</code>';
$data = "\t\t<li class=\"ez-toc-debug-message-data\">{$data}</li>" . PHP_EOL;
array_push(
$dump,
PHP_EOL . "\t<ul class=\"ez-toc-debug-message-{$code}\">" . PHP_EOL . "\t\t<li class=\"ez-toc-debug-message\">" . implode( '</li>' . PHP_EOL . '<li>' . PHP_EOL, $messages ) . '</li>' . PHP_EOL . "{$data}\t</ul>" . PHP_EOL
);
}
return '<div class="ez-toc-debug-message">' . implode( '</div>' . PHP_EOL . '<div class="ez-toc-debug-message">', $dump ) . '</div>' . PHP_EOL;
}
/**
* @since 2.0.13
*
* @return string
*/
public function __toString() {
if ( false === $this->enabled ) {
return '';
}
if ( false === $this->display ) {
return '';
}
if ( ! $this->has_errors() ) {
return '';
}
$intro = sprintf(
'You see the following because <a href="%1$s"><code>WP_DEBUG</code></a> and <a href="%1$s"><code>WP_DEBUG_DISPLAY</code></a> are enabled on this site. Please disabled these to prevent the display of these developers\' debug messages.',
'https://codex.wordpress.org/WP_DEBUG'
);
$intro = PHP_EOL . "<p>{$intro}</p>" .PHP_EOL;
$dump = $this->dump();
return PHP_EOL . "<div class='ez-toc-debug-messages'>{$intro}{$dump}</div>" . PHP_EOL;
}
}

View File

@ -0,0 +1,935 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'ezTOC_Admin' ) ) {
/**
* Class ezTOC_Admin
*/
final class ezTOC_Admin {
/**
* Setup plugin for admin use.
*
* @access private
* @since 1.0
* @static
*/
public function __construct() {
$this->hooks();
}
/**
* Add the core admin hooks.
*
* @access private
* @since 1.0
* @static
*/
private function hooks() {
global $pagenow;
if($pagenow == 'options-general.php' && isset($_REQUEST['page']) && !empty($_REQUEST['page']) &&
$_REQUEST['page'] == 'table-of-contents') {
add_action( 'admin_head', array( $this,'_clean_other_plugins_stuff' ) );
}
add_action( 'admin_init', array( $this, 'registerScripts' ) );
add_action( 'admin_menu', array( $this, 'menu' ) );
add_action( 'init', array( $this, 'registerMetaboxes' ), 99 );
add_filter( 'plugin_action_links_' . EZ_TOC_BASE_NAME, array( $this, 'pluginActionLinks' ), 10, 2 );
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
add_action('wp_ajax_eztoc_send_query_message', array( $this, 'eztoc_send_query_message'));
}
/**
* Attach to admin_head hook to hide all admin notices.
*
* @scope public
* @since 2.0.33
* @return void
* @uses remove_all_actions()
*/
public function _clean_other_plugins_stuff()
{
remove_all_actions('admin_notices');
remove_all_actions('network_admin_notices');
remove_all_actions('all_admin_notices');
remove_all_actions('user_admin_notices');
}
/**
* Callback to add the Settings link to the plugin action links.
*
* @access private
* @since 1.0
* @static
*
* @param $links
* @param $file
*
* @return array
*/
public function pluginActionLinks( $links, $file ) {
$url = add_query_arg( 'page', 'table-of-contents', self_admin_url( 'options-general.php' ) );
$setting_link = '<a href="' . esc_url( $url ) . '">' . __( 'Settings', 'easy-table-of-contents' ) . '</a> |';
$setting_link .= '<a href="https://tocwp.com/contact/" target="_blank">' . __( ' Support', 'easy-table-of-contents' ) . '</a> |';
$setting_link .= '<a href="https://tocwp.com/pricing/" target="_blank">' . __( ' Upgrade', 'easy-table-of-contents' ) . '</a> |';
$setting_link .= '<a href="https://tocwp.com/" target="_blank">' . __( ' Website', 'easy-table-of-contents' ) . '</a>';
array_push( $links, $setting_link );
return $links;
}
/**
* Register the scripts used in the admin.
*
* @access private
* @since 1.0
* @static
*/
public function registerScripts() {
$min = defined ( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_register_script( 'cn_toc_admin_script', EZ_TOC_URL . "assets/js/admin$min.js", array( 'jquery', 'wp-color-picker' ), ezTOC::VERSION, true );
wp_register_style( 'cn_toc_admin_style', EZ_TOC_URL . "assets/css/admin$min.css", array( 'wp-color-picker' ), ezTOC::VERSION );
wp_enqueue_script( 'cn_toc_admin_script' );
$data = array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'eztoc_security_nonce' => wp_create_nonce('eztoc_ajax_check_nonce'),
);
$data = apply_filters( 'eztoc_localize_filter', $data, 'eztoc_admin_data' );
wp_localize_script( 'cn_toc_admin_script', 'cn_toc_admin_data', $data );
self::inlineAdminAMPNonJS();
self::inlineAdminHeadingsPaddingJS();
self::inlineAdminDisplayHeaderLabel();
self::inlineAdminInitialView();
}
/**
* inlineAdminAMPNonJS Method
* Prints out inline AMP Non JS.
*
* @access private
* @return void
* @since 2.0.46
* @static
*/
private static function inlineAdminAMPNonJS() {
$isAmpActivated = false;
if ( function_exists('ez_toc_is_amp_activated') ) {
$isAmpActivated = ez_toc_is_amp_activated();
}
if( false == $isAmpActivated ) {
$inlineAdminAMPNonJS = <<<inlineAdminAMPNonJS
jQuery(function($) {
let tocAMPSupportOption = $(document).find("input[name='ez-toc-settings[toc-run-on-amp-pages]']");
if( tocAMPSupportOption.length > 0 ) {
$(tocAMPSupportOption).attr('disabled', true);
}
});
inlineAdminAMPNonJS;
wp_add_inline_script( 'cn_toc_admin_script', $inlineAdminAMPNonJS );
}
}
/**
* inlineAdminHeadingsPaddingJS Method
* Prints out inline AMP Non JS.
*
* @access private
* @return void
* @since 2.0.48
* @static
*/
private static function inlineAdminHeadingsPaddingJS() {
$inlineAdminHeadingsPaddingJS = <<<inlineAdminHeadingsPaddingJS
jQuery(function($) {
let headingsPaddingCheckbox = $('#eztoc-appearance').find("input[name='ez-toc-settings[headings-padding]']");
let headingsPaddingTop = $('#eztoc-appearance').find("input[name='ez-toc-settings[headings-padding-top]']");
let headingsPaddingBottom = $('#eztoc-appearance').find("input[name='ez-toc-settings[headings-padding-bottom]']");
let headingsPaddingLeft = $('#eztoc-appearance').find("input[name='ez-toc-settings[headings-padding-left]']");
let headingsPaddingRight = $('#eztoc-appearance').find("input[name='ez-toc-settings[headings-padding-right]']");
let headingsPaddingTopHTML = $(headingsPaddingTop).parent();
$(headingsPaddingTopHTML).find("input[name='ez-toc-settings[headings-padding-top]']").attr("type", "number");
$(headingsPaddingTop).parents('tr').remove();
$(headingsPaddingCheckbox).parent().append("<br/><br/><span id='headings-padding-top-container'><label for='ez-toc-settings[headings-padding-top]'><strong>Top</strong></label>&nbsp;&nbsp;&nbsp;" + $(headingsPaddingTopHTML).html() + "</span>");
$('#eztoc-appearance').find("select[name='ez-toc-settings[headings-padding-top_units]']").html('<option value="px" selected="selected">px</option>');
let headingsPaddingBottomHTML = $(headingsPaddingBottom).parent();
$(headingsPaddingBottomHTML).find("input[name='ez-toc-settings[headings-padding-bottom]']").attr("type", "number");
$(headingsPaddingBottom).parents('tr').remove();
$(headingsPaddingCheckbox).parent().append("&nbsp;&nbsp;&nbsp;&nbsp;<span id='headings-padding-bottom-container'><label for='ez-toc-settings[headings-padding-bottom]'><strong>Bottom</strong></label>&nbsp;&nbsp;&nbsp;" + $(headingsPaddingBottomHTML).html() + "</span>");
$('#eztoc-appearance').find("select[name='ez-toc-settings[headings-padding-bottom_units]']").html('<option value="px" selected="selected">px</option>');
let headingsPaddingLeftHTML = $(headingsPaddingLeft).parent();
$(headingsPaddingLeftHTML).find("input[name='ez-toc-settings[headings-padding-left]']").attr("type", "number");
$(headingsPaddingLeft).parents('tr').remove();
$(headingsPaddingCheckbox).parent().append("&nbsp;&nbsp;&nbsp;&nbsp;<span id='headings-padding-left-container'><label for='ez-toc-settings[headings-padding-left]'><strong>Left</strong></label>&nbsp;&nbsp;&nbsp;" + $(headingsPaddingLeftHTML).html() + "</span>");
$('#eztoc-appearance').find("select[name='ez-toc-settings[headings-padding-left_units]']").html('<option value="px" selected="selected">px</option>');
let headingsPaddingRightHTML = $(headingsPaddingRight).parent();
$(headingsPaddingRightHTML).find("input[name='ez-toc-settings[headings-padding-right]']").attr("type", "number");
$(headingsPaddingRight).parents('tr').remove();
$(headingsPaddingCheckbox).parent().append("&nbsp;&nbsp;&nbsp;&nbsp;<span id='headings-padding-right-container'><label for='ez-toc-settings[headings-padding-right]'><strong>Right</strong></label>&nbsp;&nbsp;&nbsp;" + $(headingsPaddingRightHTML).html() + "</span>");
$('#eztoc-appearance').find("select[name='ez-toc-settings[headings-padding-right_units]']").html('<option value="px" selected="selected">px</option>');
let headingsPaddingContainerTop = $('#eztoc-appearance').find("span#headings-padding-top-container");
let headingsPaddingContainerBottom = $('#eztoc-appearance').find("span#headings-padding-bottom-container");
let headingsPaddingContainerLeft = $('#eztoc-appearance').find("span#headings-padding-left-container");
let headingsPaddingContainerRight = $('#eztoc-appearance').find("span#headings-padding-right-container");
if($(headingsPaddingCheckbox).prop('checked') == false) {
$(headingsPaddingContainerTop).hide(500);
$(headingsPaddingContainerBottom).hide(500);
$(headingsPaddingContainerLeft).hide(500);
$(headingsPaddingContainerRight).hide(500);
$(headingsPaddingTop).val(0);
$(headingsPaddingBottom).val(0);
$(headingsPaddingLeft).val(0);
$(headingsPaddingRight).val(0);
}
$(document).on("change, click", "input[name='ez-toc-settings[headings-padding]']", function() {
if($(headingsPaddingCheckbox).prop('checked') == true) {
$(headingsPaddingContainerTop).show(500);
$(headingsPaddingContainerBottom).show(500);
$(headingsPaddingContainerLeft).show(500);
$(headingsPaddingContainerRight).show(500);
} else {
$(headingsPaddingContainerTop).hide(500);
$(headingsPaddingContainerBottom).hide(500);
$(headingsPaddingContainerLeft).hide(500);
$(headingsPaddingContainerRight).hide(500);
$(headingsPaddingTop).val(0);
$(headingsPaddingBottom).val(0);
$(headingsPaddingLeft).val(0);
$(headingsPaddingRight).val(0);
}
});
});
inlineAdminHeadingsPaddingJS;
wp_add_inline_script( 'cn_toc_admin_script', $inlineAdminHeadingsPaddingJS );
}
/**
* inlineAdminDisplayHeaderLabel Method
* Prints out inline AMP Non JS.
*
* @access private
* @return void
* @since 2.0.51
* @static
*/
private static function inlineAdminDisplayHeaderLabel() {
$inlineAdminDisplayHeaderLabel = <<<inlineAdminDisplayHeaderLabel
jQuery(function($) {
let showHeadingText = $('#eztoc-general').find("input[name='ez-toc-settings[show_heading_text]']");
let visiblityOnHeaderText = $('#eztoc-general').find("input[name='ez-toc-settings[visibility_on_header_text]']");
let headerText = $('#eztoc-general').find("input[name='ez-toc-settings[heading_text]']");
if($(showHeadingText).prop('checked') == false) {
$(visiblityOnHeaderText).parents('tr').hide(500);
$(headerText).parents('tr').hide(500);
}
$(document).on("change, click", "input[name='ez-toc-settings[show_heading_text]']", function() {
if($(this).prop('checked') == true) {
$(visiblityOnHeaderText).parents('tr').show(500);
$(headerText).parents('tr').show(500);
} else {
$(visiblityOnHeaderText).parents('tr').hide(500);
$(headerText).parents('tr').hide(500);
}
});
});
inlineAdminDisplayHeaderLabel;
wp_add_inline_script( 'cn_toc_admin_script', $inlineAdminDisplayHeaderLabel );
}
/**
* inlineAdminInitialView Method
* Prints out inline AMP Non JS.
*
* @access private
* @return void
* @since 2.0.51
* @static
*/
private static function inlineAdminInitialView() {
$inlineAdminInitialView = <<<inlineAdminInitialView
jQuery(function($) {
let visibility = $('#eztoc-general').find("input[name='ez-toc-settings[visibility]']");
let visiblityHideByDefault = $('#eztoc-general').find("input[name='ez-toc-settings[visibility_hide_by_default]']");
if($(visibility).prop('checked') == false) {
$(visiblityHideByDefault).parents('tr').hide(500);
}
$(document).on("change, click", "input[name='ez-toc-settings[visibility]']", function() {
if($(this).prop('checked') == true) {
$(visiblityHideByDefault).parents('tr').show(500);
} else {
$(visiblityHideByDefault).parents('tr').hide(500);
}
});
});
inlineAdminInitialView;
wp_add_inline_script( 'cn_toc_admin_script', $inlineAdminInitialView );
}
/**
* Callback to add plugin as a submenu page of the Options page.
*
* This also adds the action to enqueue the scripts to be loaded on plugin's admin pages only.
*
* @access private
* @since 1.0
* @static
*/
public function menu() {
$page = add_submenu_page(
'options-general.php',
esc_html__( 'Table of Contents', 'easy-table-of-contents' ),
esc_html__( 'Table of Contents', 'easy-table-of-contents' ),
'manage_options',
'table-of-contents',
array( $this, 'page' )
);
add_action( 'admin_print_styles-' . $page, array( $this, 'enqueueScripts' ) );
}
/**
* Enqueue the scripts.
*
* @access private
* @since 1.0
* @static
*/
public function enqueueScripts() {
wp_enqueue_script( 'cn_toc_admin_script' );
wp_enqueue_style( 'cn_toc_admin_style' );
}
/**
* Callback to add the action which will register the table of contents post metaboxes.
*
* Metaboxes will only be registered for the post types per user preferences.
*
* @access private
* @since 1.0
* @static
*/
public function registerMetaboxes() {
if(apply_filters('ez_toc_register_metaboxes_flag', true)){
foreach ( get_post_types() as $type ) {
if ( in_array( $type, ezTOC_Option::get( 'enabled_post_types', array() ) ) ) {
add_action( "add_meta_boxes_$type", array( $this, 'metabox' ) );
add_action( "save_post_$type", array( $this, 'save' ), 10, 3 );
}
}
}
}
/**
* Callback to register the table of contents metaboxes.
*
* @access private
* @since 1.0
* @static
*/
public function metabox() {
add_meta_box( 'ez-toc', esc_html__( 'Table of Contents', 'easy-table-of-contents' ), array( $this, 'displayMetabox' ) );
}
/**
* Callback to render the content of the table of contents metaboxes.
*
* @access private
* @since 1.0
* @static
*
* @param object $post The post object.
* @param $atts
*/
public function displayMetabox( $post, $atts ) {
// Add an nonce field so we can check for it on save.
wp_nonce_field( 'ez_toc_save', '_ez_toc_nonce' );
$suppress = get_post_meta( $post->ID, '_ez-toc-disabled', true ) == 1 ? true : false;
$insert = get_post_meta( $post->ID, '_ez-toc-insert', true ) == 1 ? true : false;
$header_label = get_post_meta( $post->ID, '_ez-toc-header-label', true );
$alignment = get_post_meta( $post->ID, '_ez-toc-alignment', true );
$headings = get_post_meta( $post->ID, '_ez-toc-heading-levels', true );
$exclude = get_post_meta( $post->ID, '_ez-toc-exclude', true );
$altText = get_post_meta( $post->ID, '_ez-toc-alttext', true );
$initial_view = get_post_meta( $post->ID, '_ez-toc-visibility_hide_by_default', true );
$hide_counter = get_post_meta( $post->ID, '_ez-toc-hide_counter', true );
if ( ! is_array( $headings ) ) {
$headings = array();
}
?>
<table class="form-table">
<tbody>
<tr>
<th scope="row"></th>
<td>
<?php if ( in_array( get_post_type( $post ), ezTOC_Option::get( 'auto_insert_post_types', array() ) ) ) :
ezTOC_Option::checkbox(
array(
'id' => 'disabled-toc',
'desc' => esc_html__( 'Disable the automatic insertion of the table of contents.', 'easy-table-of-contents' ),
'default' => $suppress,
),
$suppress
);
elseif( in_array( get_post_type( $post ), ezTOC_Option::get( 'enabled_post_types', array() ) ) ):
ezTOC_Option::checkbox(
array(
'id' => 'insert-toc',
'desc' => esc_html__( 'Insert table of contents.', 'easy-table-of-contents' ),
'default' => $insert,
),
$insert
);
endif; ?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Header Label', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::text(
array(
'id' => 'header-label',
'desc' => '<br>'.__( 'Eg: Contents, Table of Contents, Page Contents', 'easy-table-of-contents' ),
'default' => $header_label,
),
$header_label
);
?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Appearance:', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::descriptive_text(
array(
'id' => 'appearance-desc',
'desc' => '<p><strong>' . esc_html__( 'NOTE:', 'easy-table-of-contents' ) . '</strong></p>' .
'<ul>' .
'<li>' . esc_html__( 'Using the appearance options below will override the global Appearance settings.', 'easy-table-of-contents' ) . '</li>' .
'</ul>',
)
);
?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Alignment', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::select(
array(
'id' => 'toc-alignment',
'options' => array(
'none' => __( 'None (Default)', 'easy-table-of-contents' ),
'left' => __( 'Left', 'easy-table-of-contents' ),
'right' => __( 'Right', 'easy-table-of-contents' ),
'center' => __( 'Center', 'easy-table-of-contents' ),
),
'default' => $alignment,
),
$alignment
);
?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Advanced:', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::descriptive_text(
array(
'id' => 'exclude-desc',
'name' => '',
'desc' => '<p><strong>' . esc_html__( 'NOTE:', 'easy-table-of-contents' ) . '</strong></p>' .
'<ul>' .
'<li>' . esc_html__( 'Using the advanced options below will override the global advanced settings.', 'easy-table-of-contents' ) . '</li>' .
'</ul>',
)
);
?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Headings:', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::checkboxgroup(
array(
'id' => 'heading-levels',
'desc' => esc_html__( 'Select the heading to consider when generating the table of contents. Deselecting a heading will exclude it.', 'easy-table-of-contents' ),
'options' => array(
'1' => __( 'Heading 1 (h1)', 'easy-table-of-contents' ),
'2' => __( 'Heading 2 (h2)', 'easy-table-of-contents' ),
'3' => __( 'Heading 3 (h3)', 'easy-table-of-contents' ),
'4' => __( 'Heading 4 (h4)', 'easy-table-of-contents' ),
'5' => __( 'Heading 5 (h5)', 'easy-table-of-contents' ),
'6' => __( 'Heading 6 (h6)', 'easy-table-of-contents' ),
),
'default' => array(),
),
array_map( 'absint', $headings )
);
?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Initial View', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::checkbox(
array(
'id' => 'visibility_hide_by_default',
'name' => __( 'Initial View', 'easy-table-of-contents' ),
'desc' => __( 'Initially hide the table of contents.', 'easy-table-of-contents' ),
'default' => false,
),
$initial_view
);
?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Hide Counter', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::checkbox(
array(
'id' => 'hide_counter',
'name' => __( 'Hide Counter', 'easy-table-of-contents' ),
'desc' => __( 'Do not show counters for the table of contents.', 'easy-table-of-contents' ),
'default' => false,
),
$hide_counter
);
?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Alternate Headings', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::textarea(
array(
'id' => 'alttext',
'desc' => __( 'Specify alternate table of contents header string. Add the header to be replaced and the alternate header on a single line separated with a pipe <code>|</code>. Put each additional original and alternate header on its own line.', 'easy-table-of-contents' ),
'size' => 'large',
'default' => '',
),
$altText
);
?>
</td>
</tr>
<tr>
<th scope="row"></th>
<td>
<?php
ezTOC_Option::descriptive_text(
array(
'id' => 'alttext-desc',
'name' => '',
'desc' => '<p><strong>' . esc_html__( 'Examples:', 'easy-table-of-contents' ) . '</strong></p>' .
'<ul>' .
'<li>' . __( '<code>Level [1.1]|Alternate TOC Header</code> Replaces Level [1.1] in the table of contents with Alternate TOC Header.', 'easy-table-of-contents' ) . '</li>' .
'</ul>' .
'<p>' . __( '<strong>Note:</strong> This is case sensitive.', 'easy-table-of-contents' ) . '</p>',
)
);
?>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Exclude Headings', 'easy-table-of-contents' ); ?></th>
<td>
<?php
ezTOC_Option::text(
array(
'id' => 'exclude',
'desc' => __( 'Specify headings to be excluded from appearing in the table of contents. Separate multiple headings with a pipe <code>|</code>. Use an asterisk <code>*</code> as a wildcard to match other text.', 'easy-table-of-contents' ),
'size' => 'large',
'default' => '',
),
$exclude
);
?>
</td>
</tr>
<tr>
<th scope="row"></th>
<td>
<?php
ezTOC_Option::descriptive_text(
array(
'id' => 'exclude-desc',
'name' => '',
'desc' => '<p><strong>' . esc_html__( 'Examples:', 'easy-table-of-contents' ) . '</strong></p>' .
'<ul>' .
'<li>' . __( '<code>Fruit*</code> Ignore headings starting with "Fruit".', 'easy-table-of-contents' ) . '</li>' .
'<li>' . __( '<code>*Fruit Diet*</code> Ignore headings with "Fruit Diet" somewhere in the heading.', 'easy-table-of-contents' ) . '</li>' .
'<li>' . __( '<code>Apple Tree|Oranges|Yellow Bananas</code> Ignore headings that are exactly "Apple Tree", "Oranges" or "Yellow Bananas".', 'easy-table-of-contents' ) . '</li>' .
'</ul>' .
'<p>' . __( '<strong>Note:</strong> This is not case sensitive.', 'easy-table-of-contents' ) . '</p>',
)
);
?>
</td>
</tr>
</tbody>
</table>
<?php
}
/**
* Callback which saves the user preferences from the table of contents metaboxes.
*
* @access private
* @since 1.0
* @static
*
* @param int $post_id The post ID.
* @param object $post The post object.
* @param bool $update Whether this is an existing post being updated or not.
*/
public function save( $post_id, $post, $update ) {
if ( current_user_can( 'edit_post', $post_id ) &&
isset( $_REQUEST['_ez_toc_nonce'] ) &&
wp_verify_nonce( $_REQUEST['_ez_toc_nonce'], 'ez_toc_save' )
) {
// Checkboxes are present if checked, absent if not.
if ( isset( $_REQUEST['ez-toc-settings']['disabled-toc'] ) ) {
update_post_meta( $post_id, '_ez-toc-disabled', true );
} else {
update_post_meta( $post_id, '_ez-toc-disabled', false );
}
if ( isset( $_REQUEST['ez-toc-settings']['insert-toc'] ) ) {
update_post_meta( $post_id, '_ez-toc-insert', true );
} else {
update_post_meta( $post_id, '_ez-toc-insert', false );
}
if ( isset( $_REQUEST['ez-toc-settings']['header-label'] )) {
$header_label = sanitize_text_field( $_REQUEST['ez-toc-settings']['header-label'] );
update_post_meta( $post_id, '_ez-toc-header-label', $header_label );
}
if ( isset( $_REQUEST['ez-toc-settings']['toc-alignment'] ) ) {
$align_values = array(
'none',
'left',
'right',
'center'
);
$alignment = sanitize_text_field( $_REQUEST['ez-toc-settings']['toc-alignment'] );
if( in_array( $alignment, $align_values ) ) {
update_post_meta( $post_id, '_ez-toc-alignment', $alignment );
}
}
if ( isset( $_REQUEST['ez-toc-settings']['heading-levels'] ) && ! empty( $_REQUEST['ez-toc-settings']['heading-levels'] ) ) {
if ( is_array( $_REQUEST['ez-toc-settings']['heading-levels'] ) ) {
$headings = array_map( 'absint', $_REQUEST['ez-toc-settings']['heading-levels'] );
} else {
$headings = array();
}
update_post_meta( $post_id, '_ez-toc-heading-levels', $headings );
} else {
update_post_meta( $post_id, '_ez-toc-heading-levels', array() );
}
if ( isset( $_REQUEST['ez-toc-settings']['alttext'] ) && ! empty( $_REQUEST['ez-toc-settings']['alttext'] ) ) {
$alttext = '';
if ( is_string( $_REQUEST['ez-toc-settings']['alttext'] ) ) {
$alttext = trim( $_REQUEST['ez-toc-settings']['alttext'] );
/*
* This is basically `esc_html()` but does not encode quotes.
* This is to allow angle brackets and such which `wp_kses_post` would strip as "evil" scripts.
*/
$alttext = wp_check_invalid_utf8( $alttext );
$alttext = _wp_specialchars( $alttext, ENT_NOQUOTES );
}
update_post_meta( $post_id, '_ez-toc-alttext', wp_kses_post( $alttext ) );
} else {
update_post_meta( $post_id, '_ez-toc-alttext', '' );
}
if ( isset( $_REQUEST['ez-toc-settings']['visibility_hide_by_default'] ) && ! empty( $_REQUEST['ez-toc-settings']['visibility_hide_by_default'] ) ) {
update_post_meta( $post_id, '_ez-toc-visibility_hide_by_default', true );
} else {
update_post_meta( $post_id, '_ez-toc-visibility_hide_by_default', false );
}
if ( isset( $_REQUEST['ez-toc-settings']['hide_counter'] ) ) {
update_post_meta( $post_id, '_ez-toc-hide_counter', true );
} else {
update_post_meta( $post_id, '_ez-toc-hide_counter', false );
}
if ( isset( $_REQUEST['ez-toc-settings']['exclude'] ) && ! empty( $_REQUEST['ez-toc-settings']['exclude'] ) ) {
$exclude = '';
if ( is_string( $_REQUEST['ez-toc-settings']['exclude'] ) ) {
$exclude = trim( $_REQUEST['ez-toc-settings']['exclude'] );
/*
* This is basically `esc_html()` but does not encode quotes.
* This is to allow angle brackets and such which `wp_kses_post` would strip as "evil" scripts.
*/
$exclude = wp_check_invalid_utf8( $exclude );
$exclude = _wp_specialchars( $exclude, ENT_NOQUOTES );
}
update_post_meta( $post_id, '_ez-toc-exclude', wp_kses_post( $exclude ) );
} else {
update_post_meta( $post_id, '_ez-toc-exclude', '' );
}
}
}
/**
* Enqueue Admin js scripts
*
*/
public function load_scripts($pagenow){
if($pagenow == 'settings_page_table-of-contents'){
$min = defined ( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script( 'eztoc-admin-js', EZ_TOC_URL . "assets/js/eztoc-admin$min.js",array('jquery'), ezTOC::VERSION,true );
$data = array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'eztoc_security_nonce' => wp_create_nonce('eztoc_ajax_check_nonce'),
);
$data = apply_filters('eztoc_localize_filter',$data,'eztoc_admin_data');
wp_localize_script( 'eztoc-admin-js', 'eztoc_admin_data', $data );
$this->eztoc_dequeue_scripts();
}
}
/**
* This is a ajax handler function for sending email from user admin panel to us.
* @return type json string
*/
public function eztoc_send_query_message(){
if ( ! isset( $_POST['eztoc_security_nonce'] ) ){
return;
}
if ( !wp_verify_nonce( $_POST['eztoc_security_nonce'], 'eztoc_ajax_check_nonce' ) ){
return;
}
if ( !current_user_can( 'manage_options' ) ) {
return;
}
$message = $this->eztoc_sanitize_textarea_field($_POST['message']);
$email = sanitize_email($_POST['email']);
if(function_exists('wp_get_current_user')){
$user = wp_get_current_user();
$message = '<p>'.$message.'</p><br><br>'.'Query from Easy Table of Content plugin support tab';
$user_data = $user->data;
$user_email = $user_data->user_email;
if($email){
$user_email = $email;
}
//php mailer variables
$sendto = 'team@magazine3.in';
$subject = "Easy Table of Content Query";
$headers[] = 'Content-Type: text/html; charset=UTF-8';
$headers[] = 'From: '. esc_attr($user_email);
$headers[] = 'Reply-To: ' . esc_attr($user_email);
// Load WP components, no themes.
$sent = wp_mail($sendto, $subject, $message, $headers);
if($sent){
echo json_encode(array('status'=>'t'));
}else{
echo json_encode(array('status'=>'f'));
}
}
wp_die();
}
public function eztoc_sanitize_textarea_field( $str ) {
if ( is_object( $str ) || is_array( $str ) ) {
return '';
}
$str = (string) $str;
$filtered = wp_check_invalid_utf8( $str );
if ( strpos( $filtered, '<' ) !== false ) {
$filtered = wp_pre_kses_less_than( $filtered );
// This will strip extra whitespace for us.
$filtered = wp_strip_all_tags( $filtered, false );
// Use HTML entities in a special case to make sure no later
// newline stripping stage could lead to a functional tag.
$filtered = str_replace( "<\n", "&lt;\n", $filtered );
}
$filtered = trim( $filtered );
$found = false;
while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) {
$filtered = str_replace( $match[0], '', $filtered );
$found = true;
}
if ( $found ) {
// Strip out the whitespace that may now exist after removing the octets.
$filtered = trim( preg_replace( '/ +/', ' ', $filtered ) );
}
return $filtered;
}
/**
* Callback used to render the admin options page.
*
* @access private
* @since 1.0
* @static
*/
public function page() {
include EZ_TOC_PATH . '/includes/inc.admin-options-page.php';
}
/**
* Function used to dequeue unwanted scripts on ETOC settings page.
*
* @since 2.0.52
*/
public function eztoc_dequeue_scripts() {
wp_dequeue_script( 'chats-js' );
wp_dequeue_script( 'custom_wp_admin_js' );
}
}
new ezTOC_Admin();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,654 @@
<?php
// Exit if accessed directly
if ( ! defined ( 'ABSPATH' ) )
exit;
if ( ! class_exists ( 'ezTOC_WidgetSticky' ) )
{
/**
* Class ezTOC_WidgetSticky
*/
class ezTOC_WidgetSticky extends WP_Widget
{
/**
* Setup and register the table of contents widget.
*
* @access public
* @since 2.0.41
*/
public function __construct ()
{
$options = array(
'classname' => 'ez-toc-widget-sticky',
'description' => __ ( 'Display the table of contents.', 'easy-table-of-contents' )
);
parent::__construct (
'ez_toc_widget_sticky',
__ ( 'Sticky Sidebar Table of Contents', 'easy-table-of-contents' ),
$options
);
add_action ( 'admin_enqueue_scripts', array( $this, 'enqueueScripts' ) );
add_action ( 'admin_footer-widgets.php', array( $this, 'printScripts' ), 9999 );
}
/**
* Callback which registers the widget with the Widget API.
*
* @access public
* @since 2.0.41
* @static
*
* @return void
*/
public static function register ()
{
register_widget ( __CLASS__ );
}
/**
* Callback to enqueue scripts on the Widgets admin page.
*
* @access private
* @since 1 .0
*
* @param string $hook_suffix
*/
public function enqueueScripts ( $hook_suffix )
{
$min = defined ( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
if ( 'widgets.php' !== $hook_suffix )
{
return;
}
wp_enqueue_style ( 'wp-color-picker' );
wp_enqueue_script ( 'wp-color-picker' );
wp_enqueue_script ( 'underscore' );
$widgetStickyAdminCSSVersion = ezTOC::VERSION . '-' . filemtime ( EZ_TOC_PATH . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "ez-toc-widget-sticky-admin$min.css" );
wp_register_style ( 'ez-toc-widget-sticky-admin', EZ_TOC_URL . "assets/css/ez-toc-widget-sticky-admin$min.css", array(), $widgetStickyAdminCSSVersion );
wp_enqueue_style ( 'ez-toc-widget-sticky-admin', EZ_TOC_URL . "assets/css/ez-toc-widget-sticky-admin$min.css", array(), $widgetStickyAdminCSSVersion );
}
/**
* Callback to print the scripts to the Widgets admin page footer.
*
* @access private
* @since 2.0.41
*/
public function printScripts ()
{
?>
<script>
(function ($) {
function initColorPicker(widget) {
widget.find('.color-picker').wpColorPicker({
change: _.throttle(function () { // For Customizer
$(this).trigger('change');
}, 3000)
});
}
function onFormUpdate(event, widget) {
initColorPicker(widget);
}
$(document).on('widget-added widget-updated', onFormUpdate);
$(document).ready(function () {
$('#widgets-right .widget:has(.color-picker)').each(function () {
initColorPicker($(this));
});
});
}(jQuery));
</script>
<?php
}
/**
* Display the post content. Optionally allows post ID to be passed
*
* @link http://stephenharris.info/get-post-content-by-id/
* @link http://wordpress.stackexchange.com/a/143316
*
* @access public
* @since 2.0.41
*
* @param int $post_id Optional. Post ID.
*
* @return string
*/
public function the_content ( $post_id = 0 )
{
global $post;
$post = get_post ( $post_id );
setup_postdata ( $post );
ob_start ();
the_content ();
$content = ob_get_clean ();
wp_reset_postdata ();
return $content;
}
/**
* Renders the widgets.
*
* @access private
* @since 2.0.41
*
* @param array $args
* @param array $instance
*/
public function widget ( $args, $instance )
{
$min = defined ( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
if ( is_404 () || is_archive () || is_search () || ( ! is_front_page () && is_home () ) )
return;
$post = ezTOC::get ( get_the_ID () );
if( function_exists( 'post_password_required' ) ) {
if( post_password_required() ) return;
}
/**
* @link https://wordpress.org/support/topic/fatal-error-when-trying-to-access-widget-area/
*/
if ( ! $post instanceof ezTOC_Post )
return;
if ( $post -> hasTOCItems () )
{
/**
* @var string $before_widget
* @var string $after_widget
* @var string $before_title
* @var string $after_title
*/
extract ( $args );
$js_vars = array();
$js_vars[ 'appearance_options' ] = '';
$js_vars[ 'advanced_options' ] = '';
$js_vars[ 'scroll_fixed_position' ] = '30';
$js_vars[ 'sidebar_sticky_title' ] = 120;
$js_vars[ 'sidebar_sticky_title_size_unit' ] = '%';
$js_vars[ 'sidebar_sticky_title_weight' ] = '500';
$js_vars[ 'sidebar_sticky_title_color' ] = '#000';
$js_vars[ 'sidebar_width' ] = 'auto';
$js_vars[ 'sidebar_width_size_unit' ] = 'none';
$js_vars[ 'fixed_top_position' ] = '30';
$js_vars[ 'fixed_top_position_size_unit' ] = 'px';
$js_vars[ 'navigation_scroll_bar' ] = 'on';
$js_vars[ 'scroll_max_height' ] = 'auto';
$js_vars[ 'scroll_max_height_size_unit' ] = 'none';
if ( 'on' == $instance[ 'appearance_options' ] || 'on' == $instance[ 'advanced_options' ] || $js_vars[ 'scroll_fixed_position' ] != $instance[ 'scroll_fixed_position' ] ||
$js_vars[ 'scroll_fixed_position' ] != $instance[ 'scroll_fixed_position' ] ||
$js_vars[ 'sidebar_sticky_title' ] != $instance[ 'sidebar_sticky_title' ] ||
$js_vars[ 'sidebar_sticky_title_size_unit' ] != $instance[ 'sidebar_sticky_title_size_unit' ] ||
$js_vars[ 'sidebar_sticky_title_weight' ] != $instance[ 'sidebar_sticky_title_weight' ] ||
$js_vars[ 'sidebar_sticky_title_color' ] != $instance[ 'sidebar_sticky_title_color' ] ||
$js_vars[ 'sidebar_width' ] != $instance[ 'sidebar_width' ] ||
$js_vars[ 'sidebar_width_size_unit' ] != $instance[ 'sidebar_width_size_unit' ] ||
$js_vars[ 'fixed_top_position' ] != $instance[ 'fixed_top_position' ] ||
$js_vars[ 'fixed_top_position_size_unit' ] != $instance[ 'fixed_top_position_size_unit' ] ||
$js_vars[ 'navigation_scroll_bar' ] != $instance[ 'navigation_scroll_bar' ] ||
$js_vars[ 'scroll_max_height' ] != $instance[ 'scroll_max_height' ] ||
$js_vars[ 'scroll_max_height_size_unit' ] != $instance[ 'scroll_max_height_size_unit' ]
)
{
$js_vars[ 'appearance_options' ] = $instance[ 'appearance_options' ];
$js_vars[ 'advanced_options' ] = $instance[ 'advanced_options' ];
if ( empty ( $instance[ 'scroll_fixed_position' ] ) || ( ! empty ( $instance[ 'scroll_fixed_position' ] ) && ! is_int ( $instance[ 'scroll_fixed_position' ] ) && 'auto' != $instance[ 'scroll_fixed_position' ] ) )
$js_vars[ 'scroll_fixed_position' ] = '30';
else
$js_vars[ 'scroll_fixed_position' ] = $instance[ 'scroll_fixed_position' ];
if ( empty ( $instance[ 'sidebar_sticky_title' ] ) || ( ! empty ( $instance[ 'sidebar_sticky_title' ] ) && ! is_int ( $instance[ 'sidebar_sticky_title' ] ) ) )
$js_vars[ 'sidebar_sticky_title' ] = 120;
else
$js_vars[ 'sidebar_sticky_title' ] = $instance[ 'sidebar_sticky_title' ];
if ( empty ( $instance[ 'sidebar_sticky_title_size_unit' ] ) || ( ! empty ( $instance[ 'sidebar_sticky_title_size_unit' ] ) ) )
$js_vars[ 'sidebar_sticky_title_size_unit' ] = '%';
else
$js_vars[ 'sidebar_sticky_title_size_unit' ] = $instance[ 'sidebar_sticky_title_size_unit' ];
if ( empty ( $instance[ 'sidebar_sticky_title_weight' ] ) || ( ! empty ( $instance[ 'sidebar_sticky_title_weight' ] ) ) )
$js_vars[ 'sidebar_sticky_title_weight' ] = '500';
else
$js_vars[ 'sidebar_sticky_title_weight' ] = $instance[ 'sidebar_sticky_title_weight' ];
if ( empty ( $instance[ 'sidebar_sticky_title_color' ] ) || ( ! empty ( $instance[ 'sidebar_sticky_title_color' ] ) ) )
$js_vars[ 'sidebar_sticky_title_color' ] = '#000';
else
$js_vars[ 'sidebar_sticky_title_color' ] = $instance[ 'sidebar_sticky_title_color' ];
if ( empty ( $instance[ 'sidebar_width' ] ) || ( ! empty ( $instance[ 'sidebar_width' ] ) && ! is_int ( $instance[ 'sidebar_width' ] ) && 'auto' != $instance[ 'sidebar_width' ] ) )
$js_vars[ 'sidebar_width' ] = 'auto';
else
$js_vars[ 'sidebar_width' ] = $instance[ 'sidebar_width' ];
$js_vars[ 'sidebar_width_size_unit' ] = $instance[ 'sidebar_width_size_unit' ];
if ( empty ( $instance[ 'fixed_top_position' ] ) || ( ! empty ( $instance[ 'fixed_top_position' ] ) && ! is_int ( $instance[ 'fixed_top_position' ] ) && '30' != $instance[ 'fixed_top_position' ] ) )
$js_vars[ 'fixed_top_position' ] = '30';
else
$js_vars[ 'fixed_top_position' ] = $instance[ 'fixed_top_position' ];
$js_vars[ 'fixed_top_position_size_unit' ] = $instance[ 'fixed_top_position_size_unit' ];
$js_vars[ 'navigation_scroll_bar' ] = $instance[ 'navigation_scroll_bar' ];
if ( empty ( $instance[ 'scroll_max_height' ] ) || ( ! empty ( $instance[ 'scroll_max_height' ] ) && ! is_int ( $instance[ 'scroll_max_height' ] ) && 'auto' != $instance[ 'scroll_max_height' ] ) )
$js_vars[ 'scroll_max_height' ] = 'auto';
else
$js_vars[ 'scroll_max_height' ] = $instance[ 'scroll_max_height' ];
$js_vars[ 'scroll_max_height_size_unit' ] = $instance[ 'scroll_max_height_size_unit' ];
}
$class = array(
'ez-toc-widget-sticky-v' . str_replace ( '.', '_', ezTOC::VERSION ),
'ez-toc-widget-sticky',
);
$title = apply_filters ( 'widget_title', $instance[ 'title' ], $instance, $this -> id_base );
if ( false !== strpos ( $title, '%PAGE_TITLE%' ) || false !== strpos ( $title, '%PAGE_NAME%' ) )
{
$title = str_replace ( '%PAGE_TITLE%', get_the_title (), $title );
}
if ( ezTOC_Option::get ( 'show_hierarchy' ) )
{
$class[] = 'counter-hierarchy';
} else
{
$class[] = 'counter-flat';
}
if ( ezTOC_Option::get ( 'heading-text-direction', 'ltr' ) == 'ltr' )
{
$class[] = 'ez-toc-widget-sticky-container';
}
if ( ezTOC_Option::get ( 'heading-text-direction', 'ltr' ) == 'rtl' )
{
$class[] = 'ez-toc-widget-sticky-container-rtl';
}
$class[] = 'ez-toc-widget-sticky-direction';
$custom_classes = ezTOC_Option::get ( 'css_container_class', '' );
if ( 0 < strlen ( $custom_classes ) )
{
$custom_classes = explode ( ' ', $custom_classes );
$custom_classes = apply_filters ( 'ez_toc_widget_sticky_container_class', $custom_classes, $this );
if ( is_array ( $custom_classes ) )
{
$class = array_merge ( $class, $custom_classes );
}
}
$class = array_filter ( $class );
$class = array_map ( 'trim', $class );
$class = array_map ( 'sanitize_html_class', $class );
echo $before_widget;
do_action ( 'ez_toc_widget_sticky_before_widget_container' );
echo '<div id="ez-toc-widget-sticky-container" class="ez-toc-widget-sticky-container ' . implode ( ' ', $class ) . '">' . PHP_EOL;
do_action ( 'ez_toc_widget_sticky_before_widget' );
/**
* @todo Instead of inline style, use the shadow DOM.
* @link https://css-tricks.com/playing-shadow-dom/
*
* @todo Consider not outputting the style if CSS is disabled.
* @link https://wordpress.org/support/topic/inline-styling-triggers-html-validation-error/
*/
if ( 0 < strlen ( $title ) )
{
?>
<?php echo $before_title; ?>
<?php $title_font_size = $instance[ 'sidebar_sticky_title' ].$instance[ 'sidebar_sticky_title_size_unit' ] ?>
<span class="ez-toc-widget-sticky-title-container">
<style>
#<?php echo $this -> id ?> .ez-toc-widget-sticky-title {
font-size: <?php echo esc_attr ( $title_font_size ); ?>;
font-weight: <?php echo esc_attr ( $instance[ 'sidebar_sticky_title_weight' ] ); ?>;
color: <?php echo esc_attr ( $instance[ 'sidebar_sticky_title_color' ] ); ?>;
}
#<?php echo $this -> id ?> .ez-toc-widget-sticky-container ul.ez-toc-widget-sticky-list li.active{
background-color: <?php echo esc_attr ( $instance[ 'highlight_color' ] ); ?>;
}
</style>
<?php
$headerTextToggleClass = '';
$headerTextToggleStyle = '';
if ( ezTOC_Option::get( 'visibility_on_header_text' ) ) {
$headerTextToggleClass = 'ez-toc-toggle';
$headerTextToggleStyle = 'style="cursor: pointer"';
}
$header_label = '<span class="ez-toc-widget-sticky-title ' . $headerTextToggleClass . '" ' .$headerTextToggleStyle . '>' . $title . '</span>';
?>
<span class="ez-toc-widget-sticky-title-toggle">
<?php if ( 'css' != ezTOC_Option::get ( 'toc_loading' ) ): ?>
<?php
echo $header_label;
if ( ezTOC_Option::get ( 'visibility' ) )
{
echo '<a href="#" class="ez-toc-widget-sticky-pull-right ez-toc-widget-sticky-btn ez-toc-widget-sticky-btn-xs ez-toc-widget-sticky-btn-default ez-toc-widget-sticky-toggle" aria-label="Widget Easy TOC toggle icon"><span style="border: 0;padding: 0;margin: 0;position: absolute !important;height: 1px;width: 1px;overflow: hidden;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);clip-path: inset(50%);white-space: nowrap;">Toggle Table of Content</span>' . ezTOC::getTOCToggleIcon () . '</a>';
}
?>
<?php else: ?>
<?php
$toggle_view = '';
if ( ezTOC_Option::get ( 'visibility_hide_by_default' ) == true )
{
$toggle_view = "checked";
}
if( true == get_post_meta( get_the_ID(), '_ez-toc-visibility_hide_by_default', true ) ) {
$toggle_view = "checked";
}
$cssIconID = uniqid();
if ( ezTOC_Option::get( 'visibility_on_header_text' ) ) {
$htmlCSSIcon = '<label for="ez-toc-widget-sticky-cssicon-toggle-item-' . $cssIconID . '" style="cursor:pointer">' . $header_label . '<span class="ez-toc-widget-sticky-pull-right ez-toc-widget-sticky-btn ez-toc-widget-sticky-btn-xs ez-toc-widget-sticky-btn-default ez-toc-widget-sticky-toggle"><span style="border: 0;padding: 0;margin: 0;position: absolute !important;height: 1px;width: 1px;overflow: hidden;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);clip-path: inset(50%);white-space: nowrap;">Toggle Table of Content</span>' . ezTOC::getTOCToggleIcon( 'widget-with-visibility_on_header_text' ) . '</span></label>';
} else {
echo $header_label;
$htmlCSSIcon = '<label for="ez-toc-widget-sticky-cssicon-toggle-item-' . $cssIconID . '" class="ez-toc-widget-sticky-pull-right ez-toc-widget-sticky-btn ez-toc-widget-sticky-btn-xs ez-toc-widget-sticky-btn-default ez-toc-widget-sticky-toggle"><span style="border: 0;padding: 0;margin: 0;position: absolute !important;height: 1px;width: 1px;overflow: hidden;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);clip-path: inset(50%);white-space: nowrap;">Toggle Table of Content</span>' . ezTOC::getTOCToggleIcon( 'widget-with-visibility_on_header_text' ) . '</label>';
}
echo $htmlCSSIcon;
?>
<?php endif; ?>
</span>
</span>
<?php echo $after_title; ?>
<?php if ( 'css' == ezTOC_Option::get ( 'toc_loading' ) ): ?>
<label for="ez-toc-widget-sticky-cssicon-toggle-item-count-<?php $cssIconID ?>" class="cssiconcheckbox">1</label><input type="checkbox" id="ez-toc-widget-sticky-cssicon-toggle-item-<?php $cssIconID ?>" <?php $toggle_view ?> style="display:none" />
<?php endif; ?>
<?php
}
do_action ( 'ez_toc_widget_sticky_before' );
echo '<nav>' . PHP_EOL . $post -> getTOCList ( 'ez-toc-widget-sticky' ) . '</nav>' . PHP_EOL;
do_action ( 'ez_toc_widget_sticky_after' );
do_action ( 'ez_toc_widget_sticky_after_widget' );
echo '</div>' . PHP_EOL;
do_action ( 'ez_toc_widget_sticky_after_widget_container' );
echo $after_widget;
// Enqueue the script.
$widgetCSSVersion = ezTOC::VERSION . '-' . filemtime ( EZ_TOC_PATH . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "ez-toc-widget-sticky$min.css" );
wp_register_style ( 'ez-toc-widget-sticky', EZ_TOC_URL . "assets/css/ez-toc-widget-sticky$min.css", array(), $widgetCSSVersion );
wp_enqueue_style ( 'ez-toc-widget-sticky', EZ_TOC_URL . "assets/css/ez-toc-widget-sticky$min.css", array(), $widgetCSSVersion );
wp_add_inline_style ( 'ez-toc-widget-sticky', ezTOC::InlineCountingCSS ( ezTOC_Option::get ( 'heading-text-direction', 'ltr' ), 'ez-toc-widget-sticky-direction', 'ez-toc-widget-sticky-container', 'counter', 'ez-toc-widget-sticky-container' ) );
$widgetJSVersion = ezTOC::VERSION . '-' . filemtime ( EZ_TOC_PATH . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "ez-toc-widget-sticky$min.js" );
wp_register_script ( 'ez-toc-widget-stickyjs', EZ_TOC_URL . "assets/js/ez-toc-widget-sticky$min.js", array( 'jquery' ), $widgetJSVersion );
wp_enqueue_script ( 'ez-toc-widget-stickyjs', EZ_TOC_URL . "assets/js/ez-toc-widget-sticky$min.js", array( 'jquery' ), $widgetJSVersion );
if ( 0 < count ( $js_vars ) )
{
wp_localize_script ( 'ez-toc-widget-stickyjs', 'ezTocWidgetSticky', $js_vars );
}
}
}
/**
* Update the widget settings.
*
* @access private
* @since 2.0.41
*
* @param array $new_instance
* @param array $old_instance
*
* @return array
*/
public function update ( $new_instance, $old_instance )
{
$instance = $old_instance;
$instance[ 'title' ] = strip_tags ( $new_instance[ 'title' ] );
$instance[ 'highlight_color' ] = strip_tags ( $new_instance[ 'highlight_color' ] );
$instance[ 'hide_inline' ] = array_key_exists ( 'hide_inline', $new_instance ) ? $new_instance[ 'hide_inline' ] : '0';
if ( isset ( $new_instance[ 'appearance_options' ] ) && $new_instance[ 'appearance_options' ] == 'on' )
{
$instance[ 'sidebar_sticky_title' ] = ( int ) strip_tags ( $new_instance[ 'sidebar_sticky_title' ] );
$instance[ 'sidebar_sticky_title_size_unit' ] = strip_tags ( $new_instance[ 'sidebar_sticky_title_size_unit' ] );
$instance[ 'sidebar_sticky_title_weight' ] = strip_tags ( $new_instance[ 'sidebar_sticky_title_weight' ] );
$instance[ 'sidebar_sticky_title_color' ] = strip_tags ( $new_instance[ 'sidebar_sticky_title_color' ] );
} else
{
$instance[ 'sidebar_sticky_title' ] = 120;
$instance[ 'sidebar_sticky_title_size_unit' ] = '%';
$instance[ 'sidebar_sticky_title_weight' ] = '500';
$instance[ 'sidebar_sticky_title_color' ] = '#000';
}
if ( isset ( $new_instance[ 'advanced_options' ] ) && $new_instance[ 'advanced_options' ] == 'on' )
{
$instance[ 'advanced_options' ] = 'on';
$instance[ 'scroll_fixed_position' ] = ( int ) strip_tags ( $new_instance[ 'scroll_fixed_position' ] );
$instance[ 'sidebar_width' ] = ( 'auto' == $new_instance[ 'sidebar_width' ] ) ? $new_instance[ 'sidebar_width' ] : ( int ) strip_tags ( $new_instance[ 'sidebar_width' ] );
$instance[ 'sidebar_width_size_unit' ] = strip_tags ( $new_instance[ 'sidebar_width_size_unit' ] );
$instance[ 'fixed_top_position' ] = ( 'auto' == $new_instance[ 'fixed_top_position' ] ) ? $new_instance[ 'fixed_top_position' ] : ( int ) strip_tags ( $new_instance[ 'fixed_top_position' ] );
$instance[ 'fixed_top_position_size_unit' ] = strip_tags ( $new_instance[ 'fixed_top_position_size_unit' ] );
$instance[ 'navigation_scroll_bar' ] = strip_tags ( $new_instance[ 'navigation_scroll_bar' ] );
$instance[ 'scroll_max_height' ] = ( 'auto' == $new_instance[ 'scroll_max_height' ] ) ? $new_instance[ 'scroll_max_height' ] : ( int ) strip_tags ( $new_instance[ 'scroll_max_height' ] );
$instance[ 'scroll_max_height_size_unit' ] = strip_tags ( $new_instance[ 'scroll_max_height_size_unit' ] );
} else
{
$instance[ 'advanced_options' ] = '';
$instance[ 'scroll_fixed_position' ] = 30;
$instance[ 'sidebar_width' ] = 'auto';
$instance[ 'sidebar_width_size_unit' ] = 'none';
$instance[ 'fixed_top_position' ] = 30;
$instance[ 'fixed_top_position_size_unit' ] = 'px';
$instance[ 'navigation_scroll_bar' ] = 'on';
$instance[ 'scroll_max_height' ] = 'auto';
$instance[ 'scroll_max_height_size_unit' ] = 'none';
}
return $instance;
}
/**
* Displays the widget settings on the Widgets admin page.
*
* @access private
* @since 2.0.41
*
* @param array $instance
*
* @return string|void
*/
public function form ( $instance )
{
$defaults = array(
'highlight_color' => '#ededed',
'title' => 'Table of Contents',
'appearance_options' => '',
'advanced_options' => '',
'scroll_fixed_position' => 30,
'sidebar_sticky_title' => 120,
'sidebar_sticky_title_size_unit' => '%',
'sidebar_sticky_title_weight' => '500',
'sidebar_sticky_title_color' => '#000',
'sidebar_width' => 'auto',
'sidebar_width_size_unit' => 'none',
'fixed_top_position' => 30,
'fixed_top_position_size_unit' => 'px',
'navigation_scroll_bar' => 'on',
'scroll_max_height' => 'auto',
'scroll_max_height_size_unit' => 'none',
);
$instance = wp_parse_args ( ( array ) $instance, $defaults );
$highlight_color = esc_attr ( $instance[ 'highlight_color' ] );
$title_color = esc_attr ( $instance[ 'sidebar_sticky_title_color' ] );
?>
<p>
<label for="<?php echo $this -> get_field_id ( 'title' ); ?>"><?php _e ( 'Title', 'easy-table-of-contents' ); ?>:</label>
<input type="text" id="<?php echo $this -> get_field_id ( 'title' ); ?>"
name="<?php echo $this -> get_field_name ( 'title' ); ?>" value="<?php echo $instance[ 'title' ]; ?>"
style="width:100%;"/>
</p>
<div class="ez-toc-widget-appearance-title">
<input type="checkbox" class="ez_toc_widget_appearance_options" id="<?php echo $this -> get_field_id ( 'appearance_options' ); ?>" name="<?php echo $this -> get_field_name ( 'appearance_options' ); ?>" <?php ( 'on' === $instance[ 'appearance_options' ] ) ? 'checked="checked"' : ''; ?>/>
<label for="<?php echo $this -> get_field_id ( 'appearance_options' ); ?>"><?php _e ( 'Appearance', 'easy-table-of-contents' ); ?></label>
<div id="ez-toc-widget-options-container" class="ez-toc-widget-appearance-options-container">
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'sidebar_sticky_title' ); ?>"><?php _e ( 'Title Font Size', 'easy-table-of-contents' ); ?>:</label>
<input type="text" id="<?php echo $this -> get_field_id ( 'sidebar_sticky_title' ); ?>" name="<?php echo $this -> get_field_name ( 'sidebar_sticky_title' ); ?>" value="<?php echo $instance[ 'sidebar_sticky_title' ]; ?>" />
<select id="<?php echo $this -> get_field_id ( 'sidebar_sticky_title_size_unit' ); ?>" name="<?php echo $this -> get_field_name ( 'sidebar_sticky_title_size_unit' ); ?>" data-placeholder="" >
<option value="%" <?php echo ( '%' == $instance[ 'sidebar_sticky_title_size_unit' ] ) ? 'selected' : ''; ?>><?php _e ( '%', 'easy-table-of-contents' ); ?></option>
<option value="pt" <?php echo ( 'pt' == $instance[ 'sidebar_sticky_title_size_unit' ] ) ? 'selected=' : ''; ?> ><?php _e ( 'pt', 'easy-table-of-contents' ); ?></option>
<option value="px" <?php echo ( 'px' == $instance[ 'sidebar_sticky_title_size_unit' ] ) ? 'selected=' : ''; ?>><?php _e ( 'px', 'easy-table-of-contents' ); ?></option>
<option value="em" <?php echo ( 'em' == $instance[ 'sidebar_sticky_title_size_unit' ] ) ? 'selected=' : ''; ?>><?php _e ( 'em', 'easy-table-of-contents' ); ?></option>
</select>
</div>
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'sidebar_sticky_title_wgt' ); ?>"><?php _e ( 'Title Font Weight', 'easy-table-of-contents' ); ?>:</label>
<select id="<?php echo $this -> get_field_id ( 'sidebar_sticky_title_weight' ); ?>" name="<?php echo $this -> get_field_name ( 'sidebar_sticky_title_weight' ); ?>" data-placeholder="" style=" width: 60px; ">
<option value="100" <?php echo ( '100' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected' : ''; ?>><?php _e ( '100', 'easy-table-of-contents' ); ?></option>
<option value="200" <?php echo ( '200' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected=' : ''; ?> ><?php _e ( '200', 'easy-table-of-contents' ); ?></option>
<option value="300" <?php echo ( '300' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '300', 'easy-table-of-contents' ); ?></option>
<option value="400" <?php echo ( '400' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '400', 'easy-table-of-contents' ); ?></option>
<option value="500" <?php echo ( '500' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '500', 'easy-table-of-contents' ); ?></option>
<option value="600" <?php echo ( '600' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '600', 'easy-table-of-contents' ); ?></option>
<option value="700" <?php echo ( '700' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '700', 'easy-table-of-contents' ); ?></option>
<option value="800" <?php echo ( '800' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '800', 'easy-table-of-contents' ); ?></option>
<option value="900" <?php echo ( '900' == $instance[ 'sidebar_sticky_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '900', 'easy-table-of-contents' ); ?></option>
</select>
</div>
<p class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'sidebar_sticky_title_color' ); ?>" style="margin-right: 12px;"><?php _e ( 'Font Title Color:', 'easy-table-of-contents' ); ?></label><br>
<input type="text" name="<?php echo $this -> get_field_name ( 'sidebar_sticky_title_color' ); ?>" class="color-picker" id="<?php echo $this -> get_field_id ( 'sidebar_sticky_title_color' ); ?>" value="<?php echo $title_color; ?>" data-default-color="<?php echo $defaults[ 'sidebar_sticky_title_color' ]; ?>" />
</p>
<p class="ez-toc-widget-form-group" style="margin: 0;margin-top: 7px;">
<label for="<?php echo $this -> get_field_id ( 'highlight_color' ); ?>" style="margin-right: 12px;"><?php _e ( 'Active Section Highlight Color:', 'easy-table-of-contents' ); ?></label><br>
<input type="text" name="<?php echo $this -> get_field_name ( 'highlight_color' ); ?>" class="color-picker" id="<?php echo $this -> get_field_id ( 'highlight_color' ); ?>" value="<?php echo $highlight_color; ?>" data-default-color="<?php echo $defaults[ 'highlight_color' ]; ?>" />
</p>
</div>
</div>
<div class="ez-toc-widget-advanced-title">
<input type="checkbox" class="ez_toc_widget_advanced_options" id="<?php echo $this -> get_field_id ( 'advanced_options' ); ?>" name="<?php echo $this -> get_field_name ( 'advanced_options' ); ?>" <?php ( 'on' === $instance[ 'advanced_options' ] ) ? 'checked="checked"' : ''; ?>/><label for="<?php echo $this -> get_field_id ( 'advanced_options' ); ?>"><?php _e ( 'Advanced Options', 'easy-table-of-contents' ); ?></label>
<div id="ez-toc-widget-options-container" class="ez-toc-widget-advanced-options-container">
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'scroll_fixed_position' ); ?>"><?php _e ( 'Scroll Fixed Position', 'easy-table-of-contents' ); ?>:</label>
<input type="number" id="<?php echo $this -> get_field_id ( 'scroll_fixed_position' ); ?>" name="<?php echo $this -> get_field_name ( 'scroll_fixed_position' ); ?>" value="<?php echo $instance[ 'scroll_fixed_position' ]; ?>" />
</div>
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'sidebar_width' ); ?>"><?php _e ( 'Sidebar Width', 'easy-table-of-contents' ); ?>:</label>
<input type="text" id="<?php echo $this -> get_field_id ( 'sidebar_width' ); ?>" name="<?php echo $this -> get_field_name ( 'sidebar_width' ); ?>" value="<?php echo $instance[ 'sidebar_width' ]; ?>" />
<select id="<?php echo $this -> get_field_id ( 'sidebar_width_size_unit' ); ?>" name="<?php echo $this -> get_field_name ( 'sidebar_width_size_unit' ); ?>" data-placeholder="" >
<option value="pt" <?php ( 'pt' == $instance[ 'sidebar_width_size_unit' ] ) ? 'selected="selected"' : ''; ?> ><?php _e ( 'pt', 'easy-table-of-contents' ); ?></option>
<option value="px" <?php ( 'px' == $instance[ 'sidebar_width_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'px', 'easy-table-of-contents' ); ?></option>
<option value="%" <?php ( '%' == $instance[ 'sidebar_width_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( '%', 'easy-table-of-contents' ); ?></option>
<option value="em" <?php ( 'em' == $instance[ 'sidebar_width_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'em', 'easy-table-of-contents' ); ?></option>
<option value="none" <?php ( 'none' == $instance[ 'sidebar_width_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'none', 'easy-table-of-contents' ); ?></option>
</select>
</div>
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'fixed_top_position' ); ?>"><?php _e ( 'Fixed Top Position', 'easy-table-of-contents' ); ?>:</label>
<input type="text" id="<?php echo $this -> get_field_id ( 'fixed_top_position' ); ?>" name="<?php echo $this -> get_field_name ( 'fixed_top_position' ); ?>" value="<?php echo $instance[ 'fixed_top_position' ]; ?>" />
<select id="<?php echo $this -> get_field_id ( 'fixed_top_position_size_unit' ); ?>" name="<?php echo $this -> get_field_name ( 'fixed_top_position_size_unit' ); ?>" data-placeholder="" >
<option value="pt" <?php ( 'pt' == $instance[ 'fixed_top_position_size_unit' ] ) ? 'selected="selected"' : ''; ?> ><?php _e ( 'pt', 'easy-table-of-contents' ); ?></option>
<option value="px" <?php ( 'px' == $instance[ 'fixed_top_position_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'px', 'easy-table-of-contents' ); ?></option>
<option value="%" <?php ( '%' == $instance[ 'fixed_top_position_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( '%', 'easy-table-of-contents' ); ?></option>
<option value="em" <?php ( 'em' == $instance[ 'fixed_top_position_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'em', 'easy-table-of-contents' ); ?></option>
<option value="none" <?php ( 'none' == $instance[ 'fixed_top_position_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'none', 'easy-table-of-contents' ); ?></option>
</select>
</div>
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'navigation_scroll_bar' ); ?>"><?php _e ( 'Navigation Scroll Bar', 'easy-table-of-contents' ); ?>:</label>
<input type="checkbox" id="<?php echo $this -> get_field_id ( 'navigation_scroll_bar' ); ?>" name="<?php echo $this -> get_field_name ( 'navigation_scroll_bar' ); ?>" <?php ( 'on' === $instance[ 'navigation_scroll_bar' ] ) ? 'checked="checked"' : ''; ?>/>
</div>
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'scroll_max_height' ); ?>"><?php _e ( 'Scroll Max Height', 'easy-table-of-contents' ); ?>:</label>
<input type="text" id="<?php echo $this -> get_field_id ( 'scroll_max_height' ); ?>" name="<?php echo $this -> get_field_name ( 'scroll_max_height' ); ?>" value="<?php echo $instance[ 'scroll_max_height' ]; ?>" />
<select id="<?php echo $this -> get_field_id ( 'scroll_max_height_size_unit' ); ?>" name="<?php echo $this -> get_field_name ( 'scroll_max_height_size_unit' ); ?>" data-placeholder="" >
<option value="pt" <?php ( 'pt' == $instance[ 'scroll_max_height_size_unit' ] ) ? 'selected="selected"' : ''; ?> ><?php _e ( 'pt', 'easy-table-of-contents' ); ?></option>
<option value="px" <?php ( 'px' == $instance[ 'scroll_max_height_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'px', 'easy-table-of-contents' ); ?></option>
<option value="%" <?php ( '%' == $instance[ 'scroll_max_height_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( '%', 'easy-table-of-contents' ); ?></option>
<option value="em" <?php ( 'em' == $instance[ 'scroll_max_height_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'em', 'easy-table-of-contents' ); ?></option>
<option value="none" <?php ( 'none' == $instance[ 'scroll_max_height_size_unit' ] ) ? 'selected="selected"' : ''; ?>><?php _e ( 'none', 'easy-table-of-contents' ); ?></option>
</select>
</div>
</div>
</div>
<?php
}
}
// end class
add_action ( 'widgets_init', array( 'ezTOC_WidgetSticky', 'register' ) );
}

View File

@ -0,0 +1,471 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'ezTOC_Widget' ) ) {
/**
* Class ezTOC_Widget
*/
class ezTOC_Widget extends WP_Widget {
/**
* Setup and register the table of contents widget.
*
* @access public
* @since 1.0
*/
public function __construct() {
$options = array(
'classname' => 'ez-toc',
'description' => __( 'Display the table of contents.', 'easy-table-of-contents' )
);
parent::__construct(
'ezw_tco',
__( 'Table of Contents', 'easy-table-of-contents' ),
$options
);
add_action( 'admin_enqueue_scripts', array( $this, 'enqueueScripts' ) );
add_action( 'admin_footer-widgets.php', array( $this, 'printScripts' ), 9999 );
}
/**
* Callback which registers the widget with the Widget API.
*
* @access public
* @since 1.0
* @static
*
* @return void
*/
public static function register() {
register_widget( __CLASS__ );
}
/**
* Callback to enqueue scripts on the Widgets admin page.
*
* @access private
* @since 1.0
*
* @param string $hook_suffix
*/
public function enqueueScripts( $hook_suffix ) {
if ( 'widgets.php' !== $hook_suffix ) {
return;
}
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_script( 'underscore' );
}
/**
* Callback to print the scripts to the Widgets admin page footer.
*
* @access private
* @since 1.0
*/
public function printScripts() {
?>
<script>
( function( $ ){
function initColorPicker( widget ) {
widget.find( '.color-picker' ).wpColorPicker( {
change: _.throttle( function() { // For Customizer
$(this).trigger( 'change' );
}, 3000 )
});
}
function onFormUpdate( event, widget ) {
initColorPicker( widget );
}
$( document ).on( 'widget-added widget-updated', onFormUpdate );
$( document ).ready( function() {
$( '#widgets-right .widget:has(.color-picker)' ).each( function () {
initColorPicker( $( this ) );
} );
} );
}( jQuery ) );
</script>
<?php
}
/**
* Display the post content. Optionally allows post ID to be passed
*
* @link http://stephenharris.info/get-post-content-by-id/
* @link http://wordpress.stackexchange.com/a/143316
*
* @access public
* @since 1.0
*
* @param int $post_id Optional. Post ID.
*
* @return string
*/
public function the_content( $post_id = 0 ) {
global $post;
$post = get_post( $post_id );
setup_postdata( $post );
ob_start();
the_content();
$content = ob_get_clean();
wp_reset_postdata();
return $content;
}
/**
* Renders the widgets.
*
* @access private
* @since 1.0
*
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance ) {
if ( is_404() || is_archive() || is_search() || ( ! is_front_page() && is_home() ) ) return;
$post = ezTOC::get( get_the_ID() );
if( function_exists( 'post_password_required' ) ) {
if( post_password_required() ) return;
}
/**
* @link https://wordpress.org/support/topic/fatal-error-when-trying-to-access-widget-area/
*/
if ( ! $post instanceof ezTOC_Post ) return;
if ( $post->hasTOCItems() ) {
/**
* @var string $before_widget
* @var string $after_widget
* @var string $before_title
* @var string $after_title
*/
extract( $args );
$class = array(
'ez-toc-v' . str_replace( '.', '_', ezTOC::VERSION ),
'ez-toc-widget',
);
$instance_title = '';
if(isset($instance['title'])){
$instance_title = $instance['title'];
}
$title = apply_filters( 'widget_title', $instance_title, $instance, $this->id_base );
if ( false !== strpos( $title, '%PAGE_TITLE%' ) || false !== strpos( $title, '%PAGE_NAME%' ) ) {
$title = str_replace( '%PAGE_TITLE%', get_the_title(), $title );
}
if ( ezTOC_Option::get( 'show_hierarchy' ) ) {
$class[] = 'counter-hierarchy';
} else {
$class[] = 'counter-flat';
}
if( ezTOC_Option::get( 'heading-text-direction', 'ltr' ) == 'ltr' ) {
$class[] = 'ez-toc-widget-container';
}
if( ezTOC_Option::get( 'heading-text-direction', 'ltr' ) == 'rtl' ) {
$class[] = 'ez-toc-widget-container-rtl';
}
if ( isset($instance['affix']) ) {
$class[] = 'ez-toc-affix';
}
$class[] = 'ez-toc-widget-direction';
$custom_classes = ezTOC_Option::get( 'css_container_class', '' );
if ( 0 < strlen( $custom_classes ) ) {
$custom_classes = explode( ' ', $custom_classes );
$custom_classes = apply_filters( 'ez_toc_container_class', $custom_classes, $this );
if ( is_array( $custom_classes ) ) {
$class = array_merge( $class, $custom_classes );
}
}
$class = array_filter( $class );
$class = array_map( 'trim', $class );
$class = array_map( 'sanitize_html_class', $class );
echo $before_widget;
do_action( 'ez_toc_before_widget_container');
echo '<div id="ez-toc-widget-container" class="ez-toc-widget-container ' . implode( ' ', $class ) . '">' . PHP_EOL;
do_action( 'ez_toc_before_widget' );
/**
* @todo Instead of inline style, use the shadow DOM.
* @link https://css-tricks.com/playing-shadow-dom/
*
* @todo Consider not outputting the style if CSS is disabled.
* @link https://wordpress.org/support/topic/inline-styling-triggers-html-validation-error/
*/
$title_font_size = $instance[ 'sidebar_title_size' ].$instance[ 'sidebar_title_size_unit' ];
if ( 0 < strlen( $title ) ) {
?>
<?php echo $before_title; ?>
<span class="ez-toc-title-container">
<style>
#<?php echo $this->id ?> .ez-toc-title{
font-size: <?php echo esc_attr ( $title_font_size ); ?>;
font-weight: <?php echo esc_attr ( $instance[ 'sidebar_title_weight' ] ); ?>;
color: <?php echo esc_attr ( $instance[ 'sidebar_title_color' ] ); ?>;
}
#<?php echo $this->id ?> .ez-toc-widget-container ul.ez-toc-list li.active{
background-color: <?php echo esc_attr( $instance['highlight_color'] ); ?>;
}
</style>
<?php
$headerTextToggleClass = '';
$headerTextToggleStyle = '';
if ( ezTOC_Option::get( 'visibility_on_header_text' ) ) {
$headerTextToggleClass = 'ez-toc-toggle';
$headerTextToggleStyle = 'style="cursor: pointer"';
}
$header_label = '<span class="ez-toc-title ' . $headerTextToggleClass . '" ' .$headerTextToggleStyle . '>' . $title . '</span>';
?>
<span class="ez-toc-title-toggle">
<?php if ( 'css' != ezTOC_Option::get( 'toc_loading' ) ): ?>
<?php
echo $header_label;
if ( ezTOC_Option::get( 'visibility' ) ) {
echo '<a href="#" class="ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle" aria-label="Widget Easy TOC toggle icon"><span style="border: 0;padding: 0;margin: 0;position: absolute !important;height: 1px;width: 1px;overflow: hidden;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);clip-path: inset(50%);white-space: nowrap;">Toggle Table of Content</span>' . ezTOC::getTOCToggleIcon() . '</a>';
}
?>
<?php else: ?>
<?php
$toggle_view='';
if(ezTOC_Option::get('visibility_hide_by_default')==true){
$toggle_view= "checked";
}
if( true == get_post_meta( get_the_ID(), '_ez-toc-visibility_hide_by_default', true ) ) {
$toggle_view = "checked";
}
$cssIconID = uniqid();
if ( ezTOC_Option::get( 'visibility_on_header_text' ) ) {
$htmlCSSIcon = '<label for="ez-toc-cssicon-toggle-item-' . $cssIconID . '" style="cursor:pointer">' . $header_label . '<span class="ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle">' . ezTOC::getTOCToggleIcon( 'widget-with-visibility_on_header_text' ) . '</span></label>';
} else {
echo $header_label;
$htmlCSSIcon = '<label for="ez-toc-cssicon-toggle-item-' . $cssIconID . '" class="ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle">' . ezTOC::getTOCToggleIcon( 'widget-with-visibility_on_header_text' ) . '</span></label>';
}
echo $htmlCSSIcon;
?>
<?php endif; ?>
</span>
</span>
<?php echo $after_title; ?>
<?php if ( 'css' == ezTOC_Option::get( 'toc_loading' ) ): ?>
<label for="ez-toc-cssicon-toggle-item-count-<?php $cssIconID ?>" class="cssiconcheckbox">1</label><input type="checkbox" id="ez-toc-cssicon-toggle-item-<?php $cssIconID ?>" <?php $toggle_view?> style="display:none" />
<?php endif; ?>
<?php
}
do_action( 'ez_toc_before' );
echo '<nav>'. PHP_EOL . $post->getTOCList() . '</nav>' . PHP_EOL;
do_action( 'ez_toc_after' );
do_action( 'ez_toc_after_widget' );
echo '</div>' . PHP_EOL;
do_action( 'ez_toc_after_widget_container' );
echo $after_widget;
}
}
/**
* Update the widget settings.
*
* @access private
* @since 1.0
*
* @param array $new_instance
* @param array $old_instance
*
* @return array
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['affix'] = array_key_exists( 'affix', $new_instance ) ? $new_instance['affix'] : '0';
$instance['highlight_color'] = strip_tags( $new_instance['highlight_color'] );
if ( isset ( $new_instance[ 'eztoc_appearance' ] ) && $new_instance[ 'eztoc_appearance' ] == 'on' ){
$instance[ 'sidebar_title_size' ] = ( int ) strip_tags ( $new_instance[ 'sidebar_title_size' ] );
$instance[ 'sidebar_title_size_unit' ] = strip_tags ( $new_instance[ 'sidebar_title_size_unit' ] );
$instance[ 'sidebar_title_weight' ] = strip_tags ( $new_instance[ 'sidebar_title_weight' ] );
$instance[ 'sidebar_title_color' ] = strip_tags ( $new_instance[ 'sidebar_title_color' ] );
}else{
$instance[ 'sidebar_title_size' ] = 120;
$instance[ 'sidebar_title_size_unit' ] = '%';
$instance[ 'sidebar_title_weight' ] = '500';
$instance[ 'sidebar_title_color' ] = '#000';
}
$instance['hide_inline'] = array_key_exists( 'hide_inline', $new_instance ) ? $new_instance['hide_inline'] : '0';
return $instance;
}
/**
* Displays the widget settings on the Widgets admin page.
*
* @access private
* @since 1.0
*
* @param array $instance
*
* @return string|void
*/
public function form( $instance ) {
$defaults = array(
'affix' => '0',
'eztoc_appearance' => '',
'highlight_color' => '#ededed',
'title' => __('Table of Contents', 'easy-table-of-contents' ),
'sidebar_title_size' => 120,
'sidebar_title_size_unit' => '%',
'sidebar_title_weight' => '500',
'sidebar_title_color' => '#000',
);
$instance = wp_parse_args( (array) $instance, $defaults );
$highlight_color = esc_attr( $instance[ 'highlight_color' ] );
$title_color = esc_attr( $instance[ 'sidebar_title_color' ] );
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'easy-table-of-contents' ); ?>:</label>
<input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>"
name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>"
style="width:100%;"/>
</p>
<div class="ez-toc-widget-appearance-title">
<input type="checkbox" class="ez_toc_widget_appearance_options" id="<?php echo $this -> get_field_id ( 'eztoc_appearance' ); ?>" name="<?php echo $this -> get_field_name ( 'eztoc_appearance' ); ?>" <?php ( 'on' === $instance[ 'eztoc_appearance' ] ) ? 'checked="checked"' : ''; ?>/>
<label for="<?php echo $this -> get_field_id ( 'eztoc_appearance' ); ?>"><?php _e ( 'Appearance', 'easy-table-of-contents' ); ?></label>
<div id="ez-toc-widget-options-container" class="ez-toc-widget-appearance-options-container">
<p class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'sidebar_title_color' ); ?>" style="margin-right: 12px;"><?php _e ( 'Font Title Color:', 'easy-table-of-contents' ); ?></label><br>
<input type="text" name="<?php echo $this -> get_field_name ( 'sidebar_title_color' ); ?>" class="color-picker" id="<?php echo $this -> get_field_id ( 'sidebar_title_color' ); ?>" value="<?php echo $title_color; ?>" data-default-color="<?php echo $defaults[ 'sidebar_title_color' ]; ?>" />
</p>
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'sidebar_title_size' ); ?>"><?php _e ( 'Title Font Size', 'easy-table-of-contents' ); ?>:</label>
<input type="text" id="<?php echo $this -> get_field_id ( 'sidebar_title_size' ); ?>" name="<?php echo $this -> get_field_name ( 'sidebar_title_size' ); ?>" value="<?php echo $instance[ 'sidebar_title_size' ]; ?>" style="width: 60px;"/>
<select id="<?php echo $this -> get_field_id ( 'sidebar_title_size_unit' ); ?>" name="<?php echo $this -> get_field_name ( 'sidebar_title_size_unit' ); ?>" data-placeholder="" >
<option value="%" <?php echo ( '%' == $instance[ 'sidebar_title_size_unit' ] ) ? 'selected' : ''; ?>><?php _e ( '%', 'easy-table-of-contents' ); ?></option>
<option value="pt" <?php echo ( 'pt' == $instance[ 'sidebar_title_size_unit' ] ) ? 'selected=' : ''; ?> ><?php _e ( 'pt', 'easy-table-of-contents' ); ?></option>
<option value="px" <?php echo ( 'px' == $instance[ 'sidebar_title_size_unit' ] ) ? 'selected=' : ''; ?>><?php _e ( 'px', 'easy-table-of-contents' ); ?></option>
<option value="em" <?php echo ( 'em' == $instance[ 'sidebar_title_size_unit' ] ) ? 'selected=' : ''; ?>><?php _e ( 'em', 'easy-table-of-contents' ); ?></option>
</select>
</div>
<div class="ez-toc-widget-form-group">
<label for="<?php echo $this -> get_field_id ( 'sidebar_title_weight' ); ?>"><?php _e ( 'Title Font Weight', 'easy-table-of-contents' ); ?>:</label>
<select id="<?php echo $this -> get_field_id ( 'sidebar_title_weight' ); ?>" name="<?php echo $this -> get_field_name ( 'sidebar_title_weight' ); ?>" data-placeholder="" style=" width: 60px; ">
<option value="100" <?php echo ( '100' == $instance[ 'sidebar_title_weight' ] ) ? 'selected' : ''; ?>><?php _e ( '100', 'easy-table-of-contents' ); ?></option>
<option value="200" <?php echo ( '200' == $instance[ 'sidebar_title_weight' ] ) ? 'selected=' : ''; ?> ><?php _e ( '200', 'easy-table-of-contents' ); ?></option>
<option value="300" <?php echo ( '300' == $instance[ 'sidebar_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '300', 'easy-table-of-contents' ); ?></option>
<option value="400" <?php echo ( '400' == $instance[ 'sidebar_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '400', 'easy-table-of-contents' ); ?></option>
<option value="500" <?php echo ( '500' == $instance[ 'sidebar_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '500', 'easy-table-of-contents' ); ?></option>
<option value="600" <?php echo ( '600' == $instance[ 'sidebar_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '600', 'easy-table-of-contents' ); ?></option>
<option value="700" <?php echo ( '700' == $instance[ 'sidebar_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '700', 'easy-table-of-contents' ); ?></option>
<option value="800" <?php echo ( '800' == $instance[ 'sidebar_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '800', 'easy-table-of-contents' ); ?></option>
<option value="900" <?php echo ( '900' == $instance[ 'sidebar_title_weight' ] ) ? 'selected=' : ''; ?>><?php _e ( '900', 'easy-table-of-contents' ); ?></option>
</select>
</div>
<p class="ez-toc-widget-form-group">
<label for="<?php echo $this->get_field_id( 'highlight_color' ); ?>" style="margin-right: 12px;"><?php _e( 'Active Section Highlight Color:', 'easy-table-of-contents' ); ?></label><br>
<input type="text" name="<?php echo $this->get_field_name( 'highlight_color' ); ?>" class="color-picker" id="<?php echo $this->get_field_id( 'highlight_color' ); ?>" value="<?php echo $highlight_color; ?>" data-default-color="<?php echo $defaults['highlight_color']; ?>" />
</p>
</div>
</div>
<p style="display: <?php echo ezTOC_Option::get( 'widget_affix_selector' ) ? 'block' : 'none'; ?>;">
<input class="checkbox" type="checkbox" <?php checked( $instance['affix'], 1 ); ?>
id="<?php echo $this->get_field_id( 'affix' ); ?>"
name="<?php echo $this->get_field_name( 'affix' ); ?>" value="1"/>
<label for="<?php echo $this->get_field_id( 'affix' ); ?>"> <?php _e( 'Affix or pin the widget.', 'easy-table-of-contents' ); ?></label>
</p>
<p class="description" style="display: <?php echo ezTOC_Option::get( 'widget_affix_selector' ) ? 'block' : 'none'; ?>;">
<?php _e( 'If you choose to affix the widget, do not add any other widgets on the sidebar. Also, make sure you have only one instance Table of Contents widget on the page.', 'easy-table-of-contents' ); ?>
</p>
<?php
}
} // end class
add_action( 'widgets_init', array( 'ezTOC_Widget', 'register' ) );
}

View File

@ -0,0 +1,48 @@
<?php
/**
* Deactivate Feedback Template
* @since 2.0.27
*/
$current_user = wp_get_current_user();
$email = '';
if( $current_user instanceof WP_User ) {
$email = trim( $current_user->user_email );
}
$reasons = array(
1 => '<li><label><input type="radio" name="eztoc_disable_reason" required value="temporary"/>' . __('It is only temporary', 'easy-table-of-contents') . '</label></li>',
2 => '<li><label><input type="radio" name="eztoc_disable_reason" required value="stopped showing toc"/>' . __('I stopped showing TOC on my site', 'easy-table-of-contents') . '</label></li>',
3 => '<li><label><input type="radio" name="eztoc_disable_reason" required value="missing feature"/>' . __('I miss a feature', 'easy-table-of-contents') . '</label></li>
<li><input type="text" name="eztoc_disable_text[]" value="" placeholder="Please describe the feature"/></li>',
4 => '<li><label><input type="radio" name="eztoc_disable_reason" required value="technical issue"/>' . __('Technical Issue', 'easy-table-of-contents') . '</label></li>
<li><textarea name="eztoc_disable_text[]" placeholder="' . __('Can we help? Please describe your problem', 'easy-table-of-contents') . '"></textarea></li>',
5 => '<li><label><input type="radio" name="eztoc_disable_reason" required value="other plugin"/>' . __('I switched to another plugin', 'easy-table-of-contents') . '</label></li>
<li><input type="text" name="eztoc_disable_text[]" value="" placeholder="Name of the plugin"/></li>',
6 => '<li><label><input type="radio" name="eztoc_disable_reason" required value="other"/>' . __('Other reason', 'easy-table-of-contents') . '</label></li>
<li><textarea name="eztoc_disable_text[]" placeholder="' . __('Please specify, if possible', 'easy-table-of-contents') . '"></textarea></li>',
);
shuffle($reasons);
?>
<div id="eztoc-reloaded-feedback-overlay" style="display: none;">
<div id="eztoc-reloaded-feedback-content">
<form action="" method="post">
<h3><strong><?php _e('If you have a moment, please let us know why you are deactivating:', 'easy-table-of-contents'); ?></strong></h3>
<ul>
<?php
foreach ($reasons as $reason){
echo $reason;
}
?>
</ul>
<?php if( null !== $email && !empty( $email ) ) : ?>
<input type="hidden" name="eztoc_disable_from" value="<?php echo $email; ?>" />
<?php endif; ?>
<input id="eztoc-reloaded-feedback-submit" class="button button-primary" type="submit" name="eztoc_disable_submit" value="<?php _e('Submit & Deactivate', 'easy-table-of-contents'); ?>"/>
<a class="button eztoc-feedback-only-deactivate"><?php _e('Only Deactivate', 'easy-table-of-contents'); ?></a>
<a class="eztoc-feedback-not-deactivate" href="#"><?php _e('Don\'t deactivate', 'easy-table-of-contents'); ?></a>
</form>
</div>
</div>

View File

@ -0,0 +1,42 @@
/* makebetter admin css*/
/**
PLUGINS ADMIN PAGE
*/
#eztoc-reloaded-feedback-overlay {
/* Height & width depends on how you want to reveal the overlay (see JS below) */
height: 100%;
width: 100%;
position: fixed; /* Stay in place */
z-index: 10000; /* Sit on top */
left: 0;
top: 0;
background-color: rgb(120,120,120); /* Black fallback color */
background-color: rgba(0,0,0, 0.5); /* Black w/opacity */
}
#eztoc-reloaded-feedback-content {
position: relative;
top: 25%; /* 25% from the top */
width: 500px;
max-width: 100%;
margin: auto;
margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
max-height: 50%;
padding: 20px;
background-color: #fff;
overflow-y: auto;
}
#eztoc-reloaded-feedback-content textarea,
#eztoc-reloaded-feedback-content input[type="text"] { display:none;width:100%; }
.eztoc-feedback-not-deactivate { display: block; text-align: right; }
#eztoc-reloaded-feedback-content h3{
margin:5px;
}
@media screen and (max-width:400px){
#eztoc-reloaded-feedback-content {
padding:0px;
padding-bottom:50px;
}
}

View File

@ -0,0 +1,93 @@
var strict;
jQuery(document).ready(function ($) {
/**
* DEACTIVATION FEEDBACK FORM
*/
// show overlay when clicked on "deactivate"
eztoc_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="easy-table-of-contents"] .row-actions .deactivate a');
eztoc_deactivate_link_url = eztoc_deactivate_link.attr('href');
eztoc_deactivate_link.click(function (e) {
e.preventDefault();
// only show feedback form once per 30 days
var c_value = eztoc_admin_get_cookie("eztoc_hide_deactivate_feedback");
if (c_value === undefined) {
$('#eztoc-reloaded-feedback-overlay').show();
} else {
// click on the link
window.location.href = eztoc_deactivate_link_url;
}
});
// show text fields
$('#eztoc-reloaded-feedback-content input[type="radio"]').click(function () {
// show text field if there is one
var elementText = $(this).parents('li').next('li').children('input[type="text"], textarea');
$(this).parents('ul').find('input[type="text"], textarea').not(elementText).hide().val('').attr('required', false);
elementText.attr('required', 'required').show();
});
// send form or close it
$('#eztoc-reloaded-feedback-content form').submit(function (e) {
e.preventDefault();
eztoc_set_feedback_cookie();
// Send form data
$.post(ajaxurl, {
action: 'eztoc_send_feedback',
data: $('#eztoc-reloaded-feedback-content form').serialize() + "&eztoc_security_nonce=" + cn_toc_admin_data.eztoc_security_nonce
},
function (data) {
if (data == 'sent') {
// deactivate the plugin and close the popup
$('#eztoc-reloaded-feedback-overlay').remove();
window.location.href = eztoc_deactivate_link_url;
} else {
console.log('Error: ' + data);
alert(data);
}
}
);
});
$("#eztoc-reloaded-feedback-content .eztoc-feedback-only-deactivate").click(function (e) {
e.preventDefault();
eztoc_set_feedback_cookie();
$('#eztoc-reloaded-feedback-overlay').remove();
window.location.href = eztoc_deactivate_link_url;
});
// close form without doing anything
$('.eztoc-feedback-not-deactivate').click(function (e) {
$('#eztoc-reloaded-feedback-content form')[0].reset();
var elementText = $('#eztoc-reloaded-feedback-content input[type="radio"]').parents('li').next('li').children('input[type="text"], textarea');
$(elementText).parents('ul').find('input[type="text"], textarea').hide().val('').attr('required', false);
$('#eztoc-reloaded-feedback-overlay').hide();
});
function eztoc_admin_get_cookie(name) {
var i, x, y, eztoc_cookies = document.cookie.split(";");
for (i = 0; i < eztoc_cookies.length; i++)
{
x = eztoc_cookies[i].substr(0, eztoc_cookies[i].indexOf("="));
y = eztoc_cookies[i].substr(eztoc_cookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x === name)
{
return unescape(y);
}
}
}
function eztoc_set_feedback_cookie() {
// set cookie for 30 days
var exdate = new Date();
exdate.setSeconds(exdate.getSeconds() + 2592000);
document.cookie = "eztoc_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
}
});

View File

@ -0,0 +1,143 @@
<?php
/**
* Helper Functions
*
* @package saswp
* @subpackage Helper/Templates
* @copyright Copyright (c) 2016, René Hermenau
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.4.0
*/
// Exit if accessed directly
if( !defined( 'ABSPATH' ) )
exit;
/**
* Helper method to check if user is in the plugins page.
*
* @author René Hermenau
* @since 1.4.0
*
* @return bool
*/
/**
* display deactivation logic on plugins page
*
* @since 1.4.0
*/
function eztoc_is_plugins_page() {
if(function_exists('get_current_screen')){
$screen = get_current_screen();
if(is_object($screen)){
if($screen->id == 'plugins' || $screen->id == 'plugins-network'){
return true;
}
}
}
return false;
}
add_filter('admin_footer', 'eztoc_add_deactivation_feedback_modal');
function eztoc_add_deactivation_feedback_modal() {
if( !is_admin() && !eztoc_is_plugins_page()) {
return;
}
require_once EZ_TOC_PATH ."/includes/deactivate-feedback.php";
}
/**
* send feedback via email
*
* @since 1.4.0
*/
function eztoc_send_feedback() {
if( isset( $_POST['data'] ) ) {
parse_str( $_POST['data'], $form );
}
if( !isset( $form['eztoc_security_nonce'] ) || isset( $form['eztoc_security_nonce'] ) && !wp_verify_nonce( sanitize_text_field( $form['eztoc_security_nonce'] ), 'eztoc_ajax_check_nonce' ) ) {
echo 'security_nonce_not_verified';
die();
}
if ( !current_user_can( 'manage_options' ) ) {
die();
}
$text = '';
if( isset( $form['eztoc_disable_text'] ) ) {
$text = implode( "\n\r", $form['eztoc_disable_text'] );
}
$headers = array();
$from = isset( $form['eztoc_disable_from'] ) ? $form['eztoc_disable_from'] : '';
if( $from ) {
$headers[] = "From: $from";
$headers[] = "Reply-To: $from";
}
$subject = isset( $form['eztoc_disable_reason'] ) ? $form['eztoc_disable_reason'] : '(no reason given)';
if($subject == 'technical issue'){
$text = trim($text);
if(!empty($text)){
$text = 'technical issue description: '.$text;
}else{
$text = 'no description: '.$text;
}
}
$success = wp_mail( 'team@magazine3.in', $subject, $text, $headers );
echo 'sent';
die();
}
add_action( 'wp_ajax_eztoc_send_feedback', 'eztoc_send_feedback' );
function eztoc_enqueue_makebetter_email_js(){
if( !is_admin() && !eztoc_is_plugins_page()) {
return;
}
wp_enqueue_script( 'eztoc-make-better-js', EZ_TOC_URL . 'includes/feedback.js', array( 'jquery' ));
wp_enqueue_style( 'eztoc-make-better-css', EZ_TOC_URL . 'includes/feedback.css', false );
}
add_action( 'admin_enqueue_scripts', 'eztoc_enqueue_makebetter_email_js' );
add_action('wp_ajax_eztoc_subscribe_newsletter','eztoc_subscribe_for_newsletter');
function eztoc_subscribe_for_newsletter(){
if( !wp_verify_nonce( sanitize_text_field( $_POST['eztoc_security_nonce'] ), 'eztoc_ajax_check_nonce' ) ) {
echo 'security_nonce_not_verified';
die();
}
if ( !current_user_can( 'manage_options' ) ) {
die();
}
$api_url = 'http://magazine3.company/wp-json/api/central/email/subscribe';
$api_params = array(
'name' => sanitize_text_field($_POST['name']),
'email'=> sanitize_email($_POST['email']),
'website'=> sanitize_text_field($_POST['website']),
'type'=> 'etoc'
);
$response = wp_remote_post( $api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
$response = wp_remote_retrieve_body( $response );
echo $response;
die;
}

View File

@ -0,0 +1,873 @@
<div id='toc' class='wrap'>
<a href="https://tocwp.com/" target="_blank">
<img src="<?php echo plugins_url('assets/eztoc-logo.png', dirname(__FILE__)) ?>" alt="tocwp"
srcset="<?php echo plugins_url('assets/eztoc-logo.png', dirname(__FILE__)) ?> 1x, <?php echo plugins_url('assets/eztoc-logo.png', dirname(__FILE__)) ?> 2x">
</a>
<h1 style="display:none;">&nbsp;</h1>
<div class="toc-tab-panel">
<a id="eztoc-welcome" class="eztoc-tablinks" data-href="no" href="#welcome"
onclick="ezTocTabToggle(event, 'welcome')"><?php esc_html_e( 'Welcome', 'easy-table-of-contents' ) ?></a>
<a id="eztoc-default" class="eztoc-tablinks" data-href="no" href="#general-settings"
onclick="ezTocTabToggle(event, 'general')"><?php esc_html_e( 'Settings', 'easy-table-of-contents' ) ?></a>
<?php
$pro = '';
if (function_exists('ez_toc_pro_activation_link')) {
$pro = '<a id="eztoc-default" class="eztoc-tablinks ez-toc-pro-settings-link-paid" data-href="no" href="#eztoc-prosettings" onclick="ezTocTabToggle(event, \'general\')">' . esc_html__( 'PRO Settings', 'easy-table-of-contents' ) . '</a>';
}
?>
<?php echo $pro; ?>
<?php
if (!function_exists('ez_toc_pro_activation_link')) { ?>
<a class="eztoc-tablinks" id="eztoc-freevspro" href="#freevspro-support"
onclick="ezTocTabToggle(event, 'freevspro')" data-href="no"><?php esc_html_e( 'Free vs PRO', 'easy-table-of-contents' ) ?></a>
<?php }
?>
<a class="eztoc-tablinks" id="eztoc-technical" href="#technical-support"
onclick="ezTocTabToggle(event, 'technical')" data-href="no"><?php esc_html_e( 'Help & Support', 'easy-table-of-contents' ) ?></a>
<?php if (!function_exists('ez_toc_pro_activation_link')) { ?>
<a class="eztoc-tablinks" id="eztoc-upgrade" href="https://tocwp.com/pricing/" target="_blank"><?php esc_html_e( 'UPGRADE to PRO', 'easy-table-of-contents' ) ?></a>
<?php } ?>
<?php
if (function_exists('ez_toc_pro_activation_link')) {
$license_info = get_option("easytoc_pro_upgrade_license");
$license_exp = null;
if( !empty( $license_info['pro']['license_key_expires'] ) ) {
$license_exp = date( 'Y-m-d', strtotime($license_info['pro']['license_key_expires'] ) );
}
?>
<a class="eztoc-tablinks" id="eztoc-license" href="#license"
onclick="ezTocTabToggle(event, 'license')"
data-href="no"><?php esc_html_e('License', 'easy-table-of-contents') ?>
</a>
<?php
$today = date('Y-m-d');
$exp_date = $license_exp;
$date1 = date_create($today);
if($exp_date){
$date2 = date_create($exp_date);
$diff = date_diff($date1, $date2);
$days = $diff->format("%a");
$days = intval($days);
if ($days < 30) {
?>
<span class="dashicons dashicons-warning" style="color: #ffb229;position: relative;top:
15px;left: -10px;"></span>
<?php }
}
} ?>
</div><!-- /.Tab panel -->
<div class="eztoc_support_div eztoc-tabcontent" id="welcome" style="display: block;">
<p style="font-weight: bold;font-size: 30px;color: #000;"><?php esc_html_e( 'Thank YOU for using Easy Table of Content.', 'easy-table-of-contents' ) ?></p>
<p style="font-size: 18px;padding: 0 10%;line-height: 1.7;color: #000;"><?php esc_html_e( 'We strive to create the best TOC solution in WordPress. Our dedicated development team does continuous development and innovation to make sure we are able to meet your demand.', 'easy-table-of-contents' ) ?></p>
<p style="font-size: 16px;font-weight: 600;color: #000;"><?php esc_html_e( 'Please support us by Upgrading to Premium version.', 'easy-table-of-contents' ) ?></p>
<a target="_blank" href="https://tocwp.com/pricing/">
<button class="button-toc" style="display: inline-block;font-size: 20px;">
<span><?php esc_html_e( 'YES! I want to Support by UPGRADING.', 'easy-table-of-contents' ) ?></span></button>
</a>
<a href="<?php echo add_query_arg('page', 'table-of-contents', admin_url('options-general.php')); ?>"
style="text-decoration: none;">
<button class="button-toc1"
style="display: block;text-align: center;border: 0;margin: 0 auto;background: none;">
<span style="cursor: pointer;"><?php esc_html_e( 'No Thanks, I will stick with FREE version for now.', 'easy-table-of-contents' ) ?></span>
</button>
</a>
</div>
<div class="eztoc-tabcontent" id="general">
<div id="eztoc-tabs" style="margin-top: 10px;">
<a href="#eztoc-general" id="eztoc-link-general" class="active"><?php esc_html_e( 'General', 'easy-table-of-contents' ) ?></a> | <a href="#eztoc-appearance" id="eztoc-link-appearance"><?php esc_html_e( 'Appearance', 'easy-table-of-contents' ) ?></a> | <a href="#eztoc-advanced" id="eztoc-link-advanced"><?php esc_html_e( 'Advanced', 'easy-table-of-contents' ) ?></a> | <a href="#eztoc-shortcode" id="eztoc-link-shortcode"><?php esc_html_e( 'Shortcode', 'easy-table-of-contents' ) ?></a> | <a href="#eztoc-sticky" id="eztoc-link-sticky"><?php esc_html_e( 'Sticky TOC', 'easy-table-of-contents' ) ?></a> | <a href="#eztoc-compatibility" id="eztoc-link-compatibility"><?php esc_html_e( 'Compatibility', 'easy-table-of-contents' ) ?></a> | <a href="#eztoc-iesettings" id="eztoc-link-iesettings"><?php esc_html_e( 'Import/Export', 'easy-table-of-contents' ) ?></a>
</div>
<form method="post" action="<?php echo esc_url(self_admin_url('options.php')); ?>" enctype="multipart/form-data">
<div class="metabox-holder">
<div class="postbox" id="eztoc-general">
<br />
<h3><span><?php esc_html_e('General', 'easy-table-of-contents'); ?></span></h3>
<div class="inside">
<table class="form-table">
<?php do_settings_fields('ez_toc_settings_general', 'ez_toc_settings_general'); ?>
</table>
</div><!-- /.inside -->
</div><!-- /.postbox -->
</div><!-- /.metabox-holder -->
<div class="metabox-holder">
<div class="postbox" id="eztoc-appearance">
<br />
<h3><span><?php esc_html_e('Appearance', 'easy-table-of-contents'); ?></span></h3>
<div class="inside">
<table class="form-table">
<?php do_settings_fields('ez_toc_settings_appearance', 'ez_toc_settings_appearance'); ?>
</table>
</div><!-- /.inside -->
</div><!-- /.postbox -->
</div><!-- /.metabox-holder -->
<div class="metabox-holder">
<div class="postbox" id="eztoc-advanced">
<br />
<h3><span><?php esc_html_e('Advanced', 'easy-table-of-contents'); ?></span></h3>
<div class="inside">
<table class="form-table">
<?php do_settings_fields('ez_toc_settings_advanced', 'ez_toc_settings_advanced'); ?>
</table>
</div><!-- /.inside -->
</div><!-- /.postbox -->
</div><!-- /.metabox-holder -->
<div class="metabox-holder">
<div class="postbox" id="eztoc-shortcode">
<br />
<h3><span><?php esc_html_e('Shortcode', 'easy-table-of-contents'); ?></span></h3>
<div class="inside">
<table class="form-table">
<?php do_settings_fields('ez_toc_settings_shortcode', 'ez_toc_settings_shortcode'); ?>
</table>
</div><!-- /.inside -->
</div><!-- /.postbox -->
</div><!-- /.metabox-holder -->
<div class="metabox-holder">
<div class="postbox" id="eztoc-sticky">
<br />
<h3><span><?php esc_html_e('Sticky TOC', 'easy-table-of-contents'); ?></span></h3>
<div class="inside">
<table class="form-table">
<?php do_settings_fields('ez_toc_settings_sticky', 'ez_toc_settings_sticky'); ?>
</table>
</div><!-- /.inside -->
</div><!-- /.postbox -->
</div><!-- /.metabox-holder -->
<div class="metabox-holder">
<div class="postbox" id="eztoc-compatibility">
<br />
<h3><span><?php esc_html_e('Compatibility', 'easy-table-of-contents'); ?></span></h3>
<div class="inside">
<table class="form-table">
<?php do_settings_fields('ez_toc_settings_compatibility', 'ez_toc_settings_compatibility'); ?>
</table>
</div><!-- /.inside -->
</div><!-- /.postbox -->
</div><!-- /.metabox-holder -->
<div class="metabox-holder">
<div class="postbox" id="eztoc-iesettings">
<br />
<h3><span><?php esc_html_e('Import/Export Settings', 'easy-table-of-contents'); ?></span></h3>
<div class="inside">
<table class="form-table">
<tbody>
<tr>
<?php $url = wp_nonce_url(admin_url('admin-ajax.php?action=ez_toc_export_all_settings'), '_wpnonce'); ?>
<th scope="row"><?php echo __( 'Export Settings', 'easy-table-of-contents' ) ?></th>
<td>
<button type="button"><a href="<?php echo esc_url($url); ?>" style="text-decoration:none; color: black;"><?php echo __('Export', 'easy-table-of-contents'); ?></a></button>
<label> <br><?php echo __('Export all ETOC settings to json file', 'easy-table-of-contents'); ?></label>
</td>
</tr>
<tr>
<th scope="row"><?php echo __( 'Import Settings', 'easy-table-of-contents' ) ?></th>
<td>
<input type="file" name="eztoc_import_backup" id="eztoc-import-backup">
<label> <br><?php echo __('Upload json settings file to import', 'easy-table-of-contents'); ?></label>
</td>
</tr>
</tbody>
</table>
</div><!-- /.inside -->
</div><!-- /.postbox -->
</div><!-- /.metabox-holder -->
<?php if (function_exists('ez_toc_pro_activation_link')) { ?>
<div class="metabox-holder">
<div class="postbox" id="eztoc-prosettings">
<br />
<h3><span><?php esc_html_e('PRO Settings', 'easy-table-of-contents'); ?></span></h3>
<div class="inside">
<table class="form-table">
<?php do_settings_fields('ez_toc_settings_prosettings', 'ez_toc_settings_prosettings'); ?>
</table>
</div><!-- /.inside -->
</div><!-- /.postbox -->
</div><!-- /.metabox-holder -->
<?php } ?>
<?php settings_fields('ez-toc-settings'); ?>
<p class="submit">
<?php submit_button(esc_html__( 'Save Changes', 'easy-table-of-contents' ), 'primary large', 'submit', false) ; ?>
<button type="button" id="reset-options-to-default-button" class="button button-primary button-large" style="background-color: #cd3241"><?php esc_html_e( 'Reset', 'easy-table-of-contents' ) ?></button>
</p>
</form>
</div><!-- /.General Settings ended -->
<div class="eztoc_support_div eztoc-tabcontent" id="technical">
<div id="eztoc-tabs-technical">
<a href="#" onclick="ezTocTabToggle(event, 'eztoc-technical-support',
'eztoc-tabcontent-technical', 'eztoc-tablinks-technical')"
class="eztoc-tablinks-technical active"><?php echo esc_html_e('Technical Support', 'easy-table-of-contents') ?></a>
|
<a href="#" onclick="ezTocTabToggle(event, 'eztoc-technical-how-to-use',
'eztoc-tabcontent-technical', 'eztoc-tablinks-technical')"
class="eztoc-tablinks-technical"><?php echo esc_html_e('How to Use', 'easy-table-of-contents') ?></a>
|
<a href="#" onclick="ezTocTabToggle(event, 'eztoc-technical-shortcode',
'eztoc-tabcontent-technical', 'eztoc-tablinks-technical')"
class="eztoc-tablinks-technical"><?php echo esc_html_e('Shortcode', 'easy-table-of-contents') ?></a>
|
<a href="https://tocwp.com/docs/" target="_blank" class="eztoc-tablinks-technical"><?php echo
esc_html_e('Documentation', 'easy-table-of-contents') ?></a>
|
<a href="#" onclick="ezTocTabToggle(event, 'eztoc-technical-hooks-for-developers',
'eztoc-tabcontent-technical', 'eztoc-tablinks-technical')"
class="eztoc-tablinks-technical"><?php echo esc_html_e('Hooks (for Developers)', 'easy-table-of-contents') ?></a>
</div>
<div class="eztoc-form-page-ui">
<div class="eztoc-left-side">
<div class="eztoc-tabcontent-technical" id="eztoc-technical-support">
<h1><?php esc_html_e('Technical Support', 'easy-table-of-contents'); ?></h1>
<p class="ez-toc-tabcontent-technical-title-content"><?php echo esc_html_e('We are dedicated to provide Technical support & Help to our users. Use the below form for sending your questions.', 'easy-table-of-contents') ?> </p>
<p><?php echo esc_html_e('You can also contact us from ', 'easy-table-of-contents') ?><a
href="https://tocwp.com/contact/">https://tocwp.com/contact/</a>.</p>
<div class="eztoc_support_div_form" id="technical-form">
<ul>
<li>
<label class="ez-toc-support-label"><?php esc_html_e( 'Email', 'easy-table-of-contents' ) ?><span class="star-mark">*</span></label>
<div class="ez-toc-support-input">
<input type="text" id="eztoc_query_email" name="eztoc_query_email"
placeholder="<?php esc_html_e( 'Enter your Email', 'easy-table-of-contents' ) ?>" required style="width: 350px;"/>
</div>
</li>
<li>
<label class="ez-toc-support-label"><?php esc_html_e( 'Query', 'easy-table-of-contents' ) ?><span class="star-mark">*</span></label>
<div class="ez-toc-support-input">
<label for="eztoc_query_message">
<textarea rows="5" cols="50" id="eztoc_query_message"
name="eztoc_query_message"
placeholder="<?php esc_html_e( 'Write your query', 'easy-table-of-contents' ) ?>"></textarea></label>
</div>
</li>
<li>
<div class="eztoc-customer-type">
<label class="ez-toc-support-label"><?php esc_html_e( 'Type', 'easy-table-of-contents' ) ?></label>
<div class="ez-toc-support-input">
<select name="eztoc_customer_type" id="eztoc_customer_type" style="width: 350px;">
<option value="select"><?php esc_html_e( 'Select Customer Type', 'easy-table-of-contents' ) ?></option>
<option value="paid"><?php esc_html_e( 'Paid', 'easy-table-of-contents' ) ?><span> <?php esc_html_e( '(Response within 24 hrs)', 'easy-table-of-contents' ) ?></span>
</option>
<option value="free">
<?php esc_html_e( 'Free', 'easy-table-of-contents' ) ?><span> <?php esc_html_e( '( Avg Response within 48-72 hrs)', 'easy-table-of-contents' ) ?></span>
</option>
</select>
</div>
</div>
</li>
<li>
<button class="button button-primary eztoc-send-query"><?php echo esc_html_e('Send Support Request', 'easy-table-of-contents'); ?></button>
</li>
</ul>
<div class="clear"></div>
<span class="eztoc-query-success eztoc-result eztoc_hide"><?php echo esc_html_e('Message sent successfully, Please wait we will get back to you shortly', 'easy-table-of-contents'); ?></span>
<span class="eztoc-query-error eztoc-result eztoc_hide"><?php echo esc_html_e('Message not sent. please check your network connection', 'easy-table-of-contents'); ?></span>
</div>
</div>
<div class="eztoc-tabcontent-technical" id="eztoc-technical-how-to-use" style="display:
none;">
<h1><?php esc_html_e('How to Use', 'easy-table-of-contents'); ?></h1>
<p class="ez-toc-tabcontent-technical-title-content"><?php esc_html_e('You can check how to use `Easy Table of Contents`, follow the basic details below.', 'easy-table-of-contents'); ?></p>
<h3><?php esc_html_e('1. AUTOMATICALLY', 'easy-table-of-contents'); ?></h3>
<ol>
<li><?php esc_html_e('Go to the tab Settings &gt; General section, check Auto Insert', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('Select the post types which will have the table of contents automatically inserted.', 'easy-table-of-contents'); ?></li>
<li><?php esc_html_e('NOTE: The table of contents will only be automatically inserted on post types for which it has been enabled.', 'easy-table-of-contents'); ?></li>
<li><?php esc_html_e('After Auto Insert, the Position option for choosing where you want to display the `Easy Table of Contents`.', 'easy-table-of-contents'); ?></li>
</ol>
<h3><?php esc_html_e('2. MANUALLY', 'easy-table-of-contents'); ?></h3>
<p><?php esc_html_e('There are two ways for manual adding & display `Easy Table of Contents`:', 'easy-table-of-contents');
?></p>
<ol>
<li><?php esc_html_e('Using shortcode, you can copy shortcode and paste the shortcode on editor of any post type.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('Using Insert table of contents option on editor of any post type.',
'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You have to choose post types on tab General &gt; Enable Support section then `Easy Table of Contents` editor options would be shown to choose settings for particular post type.', 'easy-table-of-contents'); ?></li>
</ol>
<h3><?php esc_html_e('3. DESIGN CUSTOMIZATION', 'easy-table-of-contents');
?></h3>
<ol>
<li><?php esc_html_e('Go to tab Settings &gt; Appearance for design customization.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can change width of `Easy Table of Contents` from select Fixed or Relative sizes or you select custom width then it will be showing custom width option for enter manually width.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also choose Alignment of `Easy Table of Contents`.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also set Font Option of `Easy Table of Contents` according to your needs.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also choose Theme color of `Easy Table of Contents` on Theme Options section according to your choice.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also choose Custom Theme colors of `Easy Table of Contents`. according to your requirements', 'easy-table-of-contents');
?></li>
</ol>
<h3><?php esc_html_e('4. STICKY TABLE', 'easy-table-of-contents');
?></h3>
<ol>
<li><?php esc_html_e('Go to Sticky TOC tab to show Table of contents as sticky on your site.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('Select the post types on which sticky table of contents has been to be enabled.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also decide whether to have sticky table of contents enabled on Homepage.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also decide whether to have sticky table of contents enabled on Category|Tag.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also decide whether to have sticky table of contents enabled on Product Category.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also decide whether to have sticky table of contents enabled on Custom Taxonomy.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also decide on which device you want to show sticky table of contents Mobile or Laptop.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also decide the position of sticky table of contents on left or right.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also choose Alignment of Sticky `Easy Table of Contents`.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also decide whether the sticky toc should be opened by default on load.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can change width of Sticky `Easy Table of Contents` from select Fixed or Relative sizes or you select custom width then it will be showing custom width option for enter manually width.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can change height of Sticky `Easy Table of Contents` from select Fixed or Relative sizes or you select custom height then it will be showing custom height option for enter manually height.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can change Button Text of Sticky `Easy Table of Contents`.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also choose Click TOC Close on Mobile of Sticky `Easy Table of Contents`.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also choose Click TOC Close on desktop of Sticky `Easy Table of Contents`.', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also change title of Sticky `Easy Table of Contents`. (PRO)', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also highlight headings while scrolling of Sticky `Easy Table of Contents`. (PRO)', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also change background of highlight headings of Sticky `Easy Table of Contents`. (PRO)', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also change title of highlight headings of Sticky `Easy Table of Contents`. (PRO)', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also choose Theme color of Sticky `Easy Table of Contents` on Theme Options section according to your choice. (PRO)', 'easy-table-of-contents');
?></li>
<li><?php esc_html_e('You can also choose Custom Theme colors of Sticky `Easy Table of Contents` according to your requirements. (PRO)', 'easy-table-of-contents');
?></li>
</ol>
<h3><?php esc_html_e('5. MORE DOCUMENTATION:', 'easy-table-of-contents'); ?></h3>
<p><?php esc_html__('You can visit this link ', 'easy-table-of-contents') . '<a href="https://tocwp.com/docs/" target="_blank">' . esc_html__('More Documentation', 'easy-table-of-contents') . '</a>' . esc_html__(' for more documentation of `Easy Table of Contents`', 'easy-table-of-contents'); ?></p>
</div>
<div class="eztoc-tabcontent-technical" id="eztoc-technical-shortcode" style="display: none;">
<h1><?php esc_html_e('Shortcode', 'easy-table-of-contents'); ?></h1>
<p class="ez-toc-tabcontent-technical-title-content"><?php esc_html_e('Use the following shortcode within your content to have the table of contents display where you wish to:', 'easy-table-of-contents'); ?></p>
<table class="form-table">
<?php do_settings_fields('ez_toc_settings_shortcode', 'ez_toc_settings_shortcode'); ?>
</table>
</div>
<div class="eztoc-tabcontent-technical" id="eztoc-technical-hooks-for-developers" style="display:
none;">
<h1><?php esc_html_e('Hooks (for Developers)', 'easy-table-of-contents'); ?></h1>
<p class="ez-toc-tabcontent-technical-title-content"><?php echo esc_html_e('This plugin has been designed for easiest way & best features for the users & also as well as for the developers, any developer follow the below advanced instructions:', 'easy-table-of-contents') ?> </p>
<h2><?php echo esc_html_e('Hooks', 'easy-table-of-contents') ?></h2>
<p><?php echo esc_html_e('Developer can use these below hooks for customization of this plugin:', 'easy-table-of-contents')
?></p>
<h4><?php echo esc_html_e('Actions:', 'easy-table-of-contents') ?></h4>
<ul>
<li><code><?php echo esc_html_e('ez_toc_before', 'easy-table-of-contents') ?></code>
</li>
<li><code><?php echo esc_html_e('ez_toc_after', 'easy-table-of-contents')
?></code></li>
<li>
<code><?php echo esc_html_e('ez_toc_sticky_toggle_before', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_sticky_toggle_after', 'easy-table-of-contents')
?></code></li>
<li>
<code><?php echo esc_html_e('ez_toc_before_widget_container', 'easy-table-of-contents')
?></code></li>
<li><code><?php echo esc_html_e('ez_toc_before_widget', 'easy-table-of-contents')
?></code></li>
<li>
<code><?php echo esc_html_e('ez_toc_after_widget_container', 'easy-table-of-contents') ?></code>
</li>
<li><code><?php echo esc_html_e('ez_toc_after_widget', 'easy-table-of-contents')
?></code></li>
<li>
<code><?php echo esc_html_e('ez_toc_title', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_sticky_title', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_container_class', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_widget_sticky_container_class', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_url_anchor_target', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_sticky_enable_support', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_sticky_post_types', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_modify_icon', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('ez_toc_label_below_html', 'easy-table-of-contents') ?></code>
</li>
<li>
<code><?php echo esc_html_e('eztoc_wordpress_final_output', 'easy-table-of-contents') ?></code>
</li>
</ul>
<h4><?php echo esc_html_e('Example: adding a span tag before the `Easy Table of Contents`',
'easy-table-of-contents') ?></h4>
<p><?php echo esc_html_e("Get this following code and paste into your theme\'s function.php file:", 'easy-table-of-contents') ?></p>
<pre>
<?php
$addCustomSpanText = esc_html_e("Some Text or Element here ", 'easy-table-of-contents');
echo "
add_action( 'ez_toc_before', 'addCustomSpan' );
function addCustomSpan()
{
echo '&lt;span&gt;$addCustomSpanText&lt;/span&gt;';
}
"; ?>
</pre>
</div>
</div>
<div class="eztoc-right-side">
<div class="eztoc-bio-box" id="ez_Bio">
<h1><?php echo esc_html_e("Vision & Mission", 'easy-table-of-contents') ?></h1>
<p class="eztoc-p"><?php echo esc_html_e("We strive to provide the best TOC in the world.", 'easy-table-of-contents') ?></p>
<section class="eztoc_dev-bio">
<div class="ezoc-bio-wrap">
<img width="50px" height="50px"
src="<?php echo plugins_url('assets/ahmed-kaludi.jpg', dirname(__FILE__))
?>" alt="ahmed-kaludi"/>
<p><?php esc_html_e('Lead Dev', 'easy-table-of-contents'); ?></p>
</div>
<div class="ezoc-bio-wrap">
<img width="50px" height="50px"
src="<?php echo plugins_url('assets/Mohammed-kaludi.jpeg', dirname
(__FILE__)) ?>" alt="Mohammed-kaludi"/>
<p><?php esc_html_e('Developer', 'easy-table-of-contents'); ?></p>
</div>
<div class="ezoc-bio-wrap">
<img width="50px" height="50px"
src="<?php echo plugins_url('assets/sanjeev.jpg', dirname(__FILE__)) ?>"
alt="Sanjeev"/>
<p><?php esc_html_e('Developer', 'easy-table-of-contents'); ?></p>
</div>
</section>
<p class="eztoc_boxdesk"><?php esc_html_e('Delivering a good user experience means a lot to us, so we try our best to reply each and every question.', 'easy-table-of-contents'); ?></p>
<p class="ez-toc-company-link"><?php esc_html_e('Support the innovation & development by upgrading to PRO ', 'easy-table-of-contents'); ?> <a href="https://tocwp.com/pricing/"><?php esc_html_e('I Want To Upgrade!', 'easy-table-of-contents'); ?></a></p>
</div>
</div>
</div>
</div> <!-- /.Technical support div ended -->
<div class="eztoc_support_div eztoc-tabcontent" id="freevspro">
<div class="eztoc-wrapper">
<div class="eztoc-wr">
<div class="etoc-eztoc-img">
<span class="sp_ov"></span>
</div>
<div class="etoc-eztoc-cnt">
<h1><?php esc_html_e('UPGRADE to PRO Version', 'easy-table-of-contents'); ?></h1>
<p><?php esc_html_e('Take your Table of Contents to the NEXT Level!', 'easy-table-of-contents'); ?></p>
<a class="buy" href="#upgrade"><?php esc_html_e('Purchase Now', 'easy-table-of-contents'); ?></a>
</div>
<div class="pvf">
<div class="ext">
<div class="ex-1 e-1">
<h4><?php esc_html_e('Premium Features', 'easy-table-of-contents'); ?></h4>
<p><?php esc_html_e('Easy TOC Pro will enhances your website table of contents and takes it to a next level to help you reach more engagement and personalization with your users.', 'easy-table-of-contents'); ?></p>
</div>
<div class="ex-1 e-2">
<h4><?php esc_html_e('Continuous Innovation', 'easy-table-of-contents'); ?></h4>
<p><?php esc_html_e('We are planning to continiously build premium features and release them. We have a roadmap and we listen to our customers to turn their feedback into reality.', 'easy-table-of-contents'); ?></p>
</div>
<div class="ex-1 e-3">
<h4><?php esc_html_e('Tech Support', 'easy-table-of-contents'); ?></h4>
<p><?php esc_html_e('Get private ticketing help from our full-time technical staff & developers who helps you with the technical issues.', 'easy-table-of-contents'); ?></p>
</div>
</div><!-- /. ext -->
<div class="pvf-cnt">
<div class="pvf-tlt">
<h2><?php esc_html_e('Compare Pro vs. Free Version', 'easy-table-of-contents'); ?></h2>
<span><?php esc_html_e('See what you\'ll get with the professional version', 'easy-table-of-contents'); ?></span>
</div>
<div class="pvf-cmp">
<div class="fr">
<h1><?php esc_html_e('FREE', 'easy-table-of-contents'); ?></h1>
<div class="fr-fe">
<div class="fe-1">
<h4><?php esc_html_e('Continious Development', 'easy-table-of-contents'); ?></h4>
<p><?php esc_html_e('We take bug reports and feature requests seriously. Were continiously developing &amp; improve this product for last 2 years with passion and love.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-1">
<h4><?php esc_html_e('50+ Features', 'easy-table-of-contents'); ?></h4>
<p><?php esc_html_e('We\'re constantly expanding the plugin and make it more useful. We have wide variety of features which will fit any use-case.', 'easy-table-of-contents'); ?></p>
</div>
</div><!-- /. fr-fe -->
</div><!-- /. fr -->
<div class="pr">
<h1><?php esc_html_e('PRO', 'easy-table-of-contents'); ?></h1>
<div class="pr-fe">
<span><?php esc_html_e('Everything in Free, and:', 'easy-table-of-contents'); ?></span>
<div class="fet">
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('Gutenberg Block', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e('Easily create TOC in Gutenberg block without the need any coding or shortcode.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('Elementor Widget', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e('Easily create TOC in Elementor with the widget without the need any coding or shortcode.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('Fixed/Sticky TOC', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e('Users can faster find the content they want with sticky. Also can change the position of Sticky table of contents with different options.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('Customize Sticky TOC', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e('Users can alos customize the appearance of Sticky of the table of contents.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('View More', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e('Users can show limited number of headings on initial view and show remaining headings on clicking a button.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('Read Time', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e('Users can show estimated read time for your posts/pages inside the table of contents.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('Collapsable Sub Headings', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e('Users can show/hide sub headings of the table of contents.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e("ACF Support", 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e("Easily create TOC with your custom ACF fields.", 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('Full AMP Support', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e('Generates a table of contents with your existing setup and makes them AMP automatically.', 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e('Continuous Updates', 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e("We're continuously updating our premium features and releasing them.", 'easy-table-of-contents'); ?></p>
</div>
<div class="fe-2">
<div class="fe-t">
<img src="<?php echo plugins_url('assets/right-tick.png',
dirname(__FILE__)) ?>" alt="right-tick"/>
<h4><?php esc_html_e("Documentation", 'easy-table-of-contents'); ?></h4>
</div>
<p><?php esc_html_e("We create tutorials for every possible feature and keep it updated for you.", 'easy-table-of-contents'); ?></p>
</div>
</div><!-- /. fet -->
<div class="pr-btn">
<a href="#upgrade"><?php esc_html_e("Upgrade to Pro", 'easy-table-of-contents'); ?></a>
</div><!-- /. pr-btn -->
</div><!-- /. pr-fe -->
</div><!-- /.pr -->
</div><!-- /. pvf-cmp -->
</div><!-- /. pvf-cnt -->
<div id="upgrade" class="amp-upg">
<div class="upg-t">
<h2><?php esc_html_e("Let's Upgrade Your Easy Table of Contents", 'easy-table-of-contents'); ?></h2>
<span><?php esc_html_e("Choose your plan and upgrade in minutes!", 'easy-table-of-contents'); ?></span>
</div>
<div class="etoc-pri-lst">
<div class="pri-tb">
<a href="https://tocwp.com/checkout/?edd_action=add_to_cart&download_id=1618&edd_options[price_id]=1"
target="_blank">
<h5><?php esc_html_e("PERSONAL", 'easy-table-of-contents'); ?></h5>
<span class="d-amt"><sup>$</sup>49</span>
<span class="amt"><sup>$</sup>49</span>
<span class="s-amt"><?php esc_html_e("(Save $59)", 'easy-table-of-contents'); ?></span>
<span class="bil"><?php esc_html_e("Billed Annually", 'easy-table-of-contents'); ?></span>
<span class="s"><?php esc_html_e("1 Site License", 'easy-table-of-contents'); ?></span>
<span class="e"><?php esc_html_e("Tech Support", 'easy-table-of-contents'); ?></span>
<span class="f"><?php esc_html_e("1 year Updates", 'easy-table-of-contents'); ?> </span>
<span class="etoc-sv"><?php esc_html_e("Pro Features", 'easy-table-of-contents'); ?> </span>
<span class="pri-by"><?php esc_html_e("Buy Now", 'easy-table-of-contents'); ?></span>
</a>
</div>
<div class="pri-tb rec">
<a href="https://tocwp.com/checkout/?edd_action=add_to_cart&download_id=1618&edd_options[price_id]=2"
target="_blank">
<h5><?php esc_html_e("MULTIPLE", 'easy-table-of-contents'); ?></h5>
<span class="d-amt"><sup>$</sup>69</span>
<span class="amt"><sup>$</sup>69</span>
<span class="s-amt"><?php esc_html_e("(Save $79)", 'easy-table-of-contents'); ?></span>
<span class="bil"><?php esc_html_e("Billed Annually", 'easy-table-of-contents'); ?></span>
<span class="s"><?php esc_html_e("3 Site License", 'easy-table-of-contents'); ?></span>
<span class="e"><?php esc_html_e("Tech Support", 'easy-table-of-contents'); ?></span>
<span class="f"><?php esc_html_e("1 year Updates", 'easy-table-of-contents'); ?></span>
<span class="etoc-sv"><?php esc_html_e("Save 78%", 'easy-table-of-contents'); ?></span>
<span class="pri-by"><?php esc_html_e("Buy Now", 'easy-table-of-contents'); ?></span>
<span class="etoc-rcm"><?php esc_html_e("RECOMMENDED", 'easy-table-of-contents'); ?></span>
</a>
</div>
<div class="pri-tb">
<a href="https://tocwp.com/checkout/?edd_action=add_to_cart&download_id=1618&edd_options[price_id]=3"
target="_blank">
<h5><?php esc_html_e("WEBMASTER", 'easy-table-of-contents'); ?></h5>
<span class="d-amt"><sup>$</sup>79</span>
<span class="amt"><sup>$</sup>79</span>
<span class="s-amt"><?php esc_html_e("(Save $99)", 'easy-table-of-contents'); ?></span>
<span class="bil"><?php esc_html_e("Billed Annually", 'easy-table-of-contents'); ?></span>
<span class="s"><?php esc_html_e("10 Site License", 'easy-table-of-contents'); ?></span>
<span class="e"><?php esc_html_e("Tech Support", 'easy-table-of-contents'); ?></span>
<span class="f"><?php esc_html_e("1 year Updates", 'easy-table-of-contents'); ?></span>
<span class="etoc-sv"><?php esc_html_e("Save 83%", 'easy-table-of-contents'); ?></span>
<span class="pri-by"><?php esc_html_e("Buy Now", 'easy-table-of-contents'); ?></span>
</a>
</div>
<div class="pri-tb">
<a href="https://tocwp.com/checkout/?edd_action=add_to_cart&download_id=1618&edd_options[price_id]=4"
target="_blank">
<h5><?php esc_html_e("FREELANCER", 'easy-table-of-contents'); ?></h5>
<span class="d-amt"><sup>$</sup>99</span>
<span class="amt"><sup>$</sup>99</span>
<span class="s-amt"><?php esc_html_e("(Save $119)", 'easy-table-of-contents'); ?></span>
<span class="bil"><?php esc_html_e("Billed Annually", 'easy-table-of-contents'); ?></span>
<span class="s"><?php esc_html_e("25 Site License", 'easy-table-of-contents'); ?></span>
<span class="e"><?php esc_html_e("Tech Support", 'easy-table-of-contents'); ?></span>
<span class="f"><?php esc_html_e("1 year Updates", 'easy-table-of-contents'); ?></span>
<span class="etoc-sv"><?php esc_html_e("Save 90%", 'easy-table-of-contents'); ?></span>
<span class="pri-by"><?php esc_html_e("Buy Now", 'easy-table-of-contents'); ?></span>
</a>
</div>
<div class="pri-tb">
<a href="https://tocwp.com/checkout/?edd_action=add_to_cart&download_id=1618&edd_options[price_id]=5"
target="_blank">
<h5><?php esc_html_e("AGENCY", 'easy-table-of-contents'); ?></h5>
<span class="d-amt"><sup>$</sup>199</span>
<span class="amt"><sup>$</sup>199</span>
<span class="s-amt"><?php esc_html_e("(Save $199)", 'easy-table-of-contents'); ?></span>
<span class="bil"><?php esc_html_e("Billed Annually", 'easy-table-of-contents'); ?></span>
<span class="s"><?php esc_html_e("Unlimited Sites", 'easy-table-of-contents'); ?></span>
<span class="e"><?php esc_html_e("E-mail support", 'easy-table-of-contents'); ?></span>
<span class="f"><?php esc_html_e("1 year Updates", 'easy-table-of-contents'); ?></span>
<span class="etoc-sv"><?php esc_html_e("UNLIMITED", 'easy-table-of-contents'); ?></span>
<span class="pri-by"><?php esc_html_e("Buy Now", 'easy-table-of-contents'); ?></span>
</a>
</div>
<div class="pri-tb">
<a href="https://tocwp.com/checkout/?edd_action=add_to_cart&download_id=1618&edd_options[price_id]=6"
target="_blank">
<h5><?php esc_html_e("LIFETIME", 'easy-table-of-contents'); ?></h5>
<span class="d-amt"><sup>$</sup>499</span>
<span class="amt"><sup>$</sup>499</span>
<span class="s-amt"><?php esc_html_e("(Save $199)", 'easy-table-of-contents'); ?></span>
<span class="bil"><?php esc_html_e("One-Time Fee", 'easy-table-of-contents'); ?></span>
<span class="s"><?php esc_html_e("Unlimited Sites", 'easy-table-of-contents'); ?></span>
<span class="e"><?php esc_html_e("Unlimited E-mail support", 'easy-table-of-contents'); ?></span>
<span class="f"><?php esc_html_e("Lifetime License", 'easy-table-of-contents'); ?></span>
<span class="etoc-sv"><?php esc_html_e("UNLIMITED", 'easy-table-of-contents'); ?></span>
<span class="pri-by"><?php esc_html_e("Buy Now", 'easy-table-of-contents'); ?></span>
</a>
</div>
</div><!-- /.pri-lst -->
<div class="tru-us">
<img src="<?php echo plugins_url('assets/toc-rating.png', dirname(__FILE__))
?>" alt="toc-rating"/>
<h2><?php esc_html_e("Used by more than 5,00,000+ Users!", 'easy-table-of-contents'); ?></h2>
<p><?php esc_html_e("More than 500k Websites, Blogs &amp; E-Commerce shops are powered by our easy table of contents plugin making it the #1 Independent TOC plugin in WordPress.", 'easy-table-of-contents'); ?></p>
<a href="https://wordpress.org/support/plugin/easy-table-of-contents/reviews/?filter=5"
target="_blank"><?php esc_html_e("Read The Reviews", 'easy-table-of-contents'); ?></a>
</div>
</div><!--/ .amp-upg -->
<div class="ampfaq">
<h2><?php esc_html_e("Frequently Asked Questions", 'easy-table-of-contents'); ?></h2>
<div class="faq-lst">
<div class="lt">
<ul>
<li>
<span><?php esc_html_e("Is there a setup fee?", 'easy-table-of-contents'); ?></span>
<p><?php esc_html_e("No. There are no setup fees on any of our plans", 'easy-table-of-contents'); ?></p>
</li>
<li>
<span><?php esc_html_e("What's the time span for your contracts?", 'easy-table-of-contents'); ?></span>
<p><?php esc_html_e("All the plans are year-to-year which are subscribed annually except for lifetime plan.", 'easy-table-of-contents'); ?></p>
</li>
<li>
<span><?php echo esc_html_e("What payment methods are accepted?", 'easy-table-of-contents') ?></span>
<p><?php echo esc_html_e("We accepts PayPal and Credit Card payments.", 'easy-table-of-contents') ?></p>
</li>
<li>
<span><?php echo esc_html_e("Do you offer support if I need help?", 'easy-table-of-contents') ?></span>
<p><?php echo esc_html_e("Yes! Top-notch customer support for our paid customers is key for a quality product, so well do our very best to resolve any issues you encounter via our support page.", 'easy-table-of-contents') ?></p>
</li>
<li>
<span><?php echo esc_html_e("Can I use the plugins after my subscription is expired?", 'easy-table-of-contents') ?></span>
<p><?php echo esc_html_e("Yes, you can use the plugins, but you will not get future updates for those plugins.", 'easy-table-of-contents') ?></p>
</li>
</ul>
</div>
<div class="rt">
<ul>
<li>
<span><?php echo esc_html_e("Can I cancel my membership at any time?", 'easy-table-of-contents') ?></span>
<p><?php echo esc_html_e("Yes. You can cancel your membership by contacting us.", 'easy-table-of-contents') ?></p>
</li>
<li>
<span><?php echo esc_html_e("Can I change my plan later on?", 'easy-table-of-contents') ?></span>
<p><?php echo esc_html_e("Yes. You can upgrade your plan by contacting us.", 'easy-table-of-contents') ?></p>
</li>
<li>
<span><?php echo esc_html_e("Do you offer refunds?", 'easy-table-of-contents') ?></span>
<p><?php echo esc_html_e("You are fully protected by our 100% Money-Back Guarantee Unconditional. If during the next 14 days you experience an issue that makes the plugin unusable, and we are unable to resolve it, well happily offer a full refund.", 'easy-table-of-contents') ?></p>
</li>
<li>
<span><?php echo esc_html_e("Do I get updates for the premium plugin?", 'easy-table-of-contents') ?></span>
<p><?php echo esc_html_e("Yes, you will get updates for all the premium plugins until your subscription is active.", 'easy-table-of-contents') ?></p>
</li>
</ul>
</div>
</div><!-- /.faq-lst -->
<div class="f-cnt">
<span><?php echo esc_html_e("I have other pre-sale questions, can you help?", 'easy-table-of-contents') ?></span>
<p><?php echo esc_html_e("All the plans are year-to-year which are subscribed annually.", 'easy-table-of-contents') ?></p>
<a href="https://tocwp.com/contact/'?utm_source=tocwp-plugin&utm_medium=addon-card'"
target="_blank"><?php echo esc_html_e("Contact a Human", 'easy-table-of-contents') ?></a>
</div><!-- /.f-cnt -->
</div><!-- /.faq -->
</div><!-- /. pvf -->
</div>
</div>
</div><!-- /.freevspro div ended -->
<div id="license" class="eztoc_support_div eztoc-tabcontent">
<?php
do_action("admin_upgrade_license_page");
?>
</div>
<!--<details id="eztoc-ocassional-pop-up-container" open>
<summary class="eztoc-ocassional-pop-up-open-close-button"><?php esc_html_e('40% OFF - Limited Time Only', 'easy-table-of-contents'); ?><svg fill="#fff" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 288.359 288.359" style="enable-background:new 0 0 288.359 288.359;" xml:space="preserve"><g><path d="M283.38,4.98c-3.311-3.311-7.842-5.109-12.522-4.972L163.754,3.166c-4.334,0.128-8.454,1.906-11.52,4.972L4.979,155.394 c-6.639,6.639-6.639,17.402,0,24.041L108.924,283.38c6.639,6.639,17.402,6.639,24.041,0l147.256-147.256 c3.065-3.065,4.844-7.186,4.972-11.52l3.159-107.103C288.49,12.821,286.691,8.291,283.38,4.98z M247.831,130.706L123.128,255.407 c-1.785,1.785-4.679,1.785-6.464,0l-83.712-83.712c-1.785-1.785-1.785-4.679,0-6.464L157.654,40.529 c1.785-1.785,4.679-1.785,6.464,0l83.713,83.713C249.616,126.027,249.616,128.921,247.831,130.706z M263.56,47.691 c-6.321,6.322-16.57,6.322-22.892,0c-6.322-6.321-6.322-16.57,0-22.892c6.321-6.322,16.569-6.322,22.892,0 C269.882,31.121,269.882,41.37,263.56,47.691z"/><path d="M99.697,181.278c-5.457,2.456-8.051,3.32-10.006,1.364c-1.592-1.591-1.5-4.411,1.501-7.412 c1.458-1.458,2.927-2.52,4.26-3.298c1.896-1.106,2.549-3.528,1.467-5.438l-0.018-0.029c-0.544-0.96-1.455-1.658-2.522-1.939 c-1.067-0.279-2.202-0.116-3.147,0.453c-1.751,1.054-3.64,2.48-5.587,4.428c-7.232,7.23-7.595,15.599-2.365,20.829 c4.457,4.457,10.597,3.956,17.463,0.637c5.004-2.364,7.55-2.729,9.46-0.819c2.002,2.002,1.638,5.004-1.545,8.186 c-1.694,1.694-3.672,3.044-5.582,4.06c-0.994,0.528-1.728,1.44-2.027,2.525c-0.3,1.085-0.139,2.245,0.443,3.208l0.036,0.06 c1.143,1.889,3.575,2.531,5.503,1.457c2.229-1.241,4.732-3.044,6.902-5.215c8.412-8.412,8.002-16.736,2.864-21.875 C112.475,178.141,107.109,177.868,99.697,181.278z"/><path d="M150.245,157.91l-31.508-16.594c-1.559-0.821-3.47-0.531-4.716,0.714l-4.897,4.898c-1.25,1.25-1.537,3.169-0.707,4.73 l16.834,31.654c0.717,1.347,2.029,2.274,3.538,2.5c1.509,0.225,3.035-0.278,4.114-1.357c1.528-1.528,1.851-3.89,0.786-5.771 l-3.884-6.866l8.777-8.777l6.944,3.734c1.952,1.05,4.361,0.696,5.928-0.871c1.129-1.129,1.654-2.726,1.415-4.303 C152.63,160.023,151.657,158.653,150.245,157.91z M125.621,165.632c0,0-7.822-13.37-9.187-15.644l0.091-0.092 c2.274,1.364,15.872,8.959,15.872,8.959L125.621,165.632z"/><path d="M173.694,133.727c-1.092,0-2.139,0.434-2.911,1.205l-9.278,9.278l-21.352-21.352c-0.923-0.923-2.175-1.441-3.479-1.441 s-2.557,0.519-3.479,1.441c-1.922,1.922-1.922,5.037,0,6.958l24.331,24.332c1.57,1.569,4.115,1.569,5.685,0l13.395-13.395 c1.607-1.607,1.607-4.213,0-5.821C175.833,134.16,174.786,133.727,173.694,133.727z"/><path d="M194.638,111.35l-9.755,9.755l-7.276-7.277l8.459-8.458c1.557-1.558,1.557-4.081-0.001-5.639 c-1.557-1.557-4.082-1.557-5.639,0l-8.458,8.458l-6.367-6.366l9.117-9.117c1.57-1.57,1.57-4.115,0-5.686 c-0.754-0.755-1.776-1.179-2.843-1.179c-1.066,0-2.089,0.424-2.843,1.178l-13.234,13.233c-0.753,0.754-1.177,1.776-1.177,2.843 c0,1.066,0.424,2.089,1.178,2.843l24.968,24.968c1.57,1.569,4.115,1.569,5.685,0l13.87-13.87c1.57-1.57,1.57-4.115,0-5.686 C198.752,109.78,196.208,109.78,194.638,111.35z"/></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g></svg></summary>
<span class="eztoc-promotion-close-btn"> &times; </span>
<div class="eztoc-ocassional-pop-up-contents">
<img src="<?php plugins_url('assets/offer-gift-icon.png', dirname(__FILE__)) ?>" class="eztoc-promotion-surprise-icon" />
<p class="eztoc-ocassional-pop-up-headline"><?php esc_html_e('40% OFF on', 'easy-table-of-contents'); ?> <span><?php esc_html_e('Easy TOC PRO', 'easy-table-of-contents');?></span></p>
<p class="eztoc-ocassional-pop-up-second-headline"><?php esc_html_e('Upgrade the PRO version during this festive season and get our biggest discount of all time on New Purchases, Renewals &amp; Upgrades', 'easy-table-of-contents'); ?></p>
<a class="eztoc-ocassional-pop-up-offer-btn" href="<?php esc_url('https://tocwp.com/november-deal/') ?>" target="_blank"><?php esc_html_e('Get This Offer Now', 'easy-table-of-contents'); ?></a>
<p class="eztoc-ocassional-pop-up-last-line"><?php esc_html_e('Black Friday, Cyber Monday, Christmas &amp; New year are the only times we offer discounts this big.', 'easy-table-of-contents'); ?> </p>
</div>
</details>-->
</div>

View File

@ -0,0 +1,380 @@
<?php
namespace Easy_Plugins\Table_Of_Contents\Cord;
/**
* Replace `<br />` tags with parameter.
*
* @since 2.0.8
*
* @param string $string
* @param string $to
*
* @return string
*/
function br2( $string, $to = "\r\n" ) {
$string = preg_replace( '`<br[/\s]*>`i', $to, $string );
return $string;
}
/**
* Replace `<br />` tags with new lines.
*
* @link https://stackoverflow.com/a/27509016/5351316
*
* @since 2.0.8
*
* @param string $string
*
* @return string
*/
function br2nl( $string ) {
return br2( $string );
}
/**
* Pulled from WordPress formatting functions.
*
* Edited to add space before self closing tags.
*
* @since 2.0
*
* @param string $text
*
* @return string|string[]
*/
function force_balance_tags( $text ) {
$tagstack = array();
$stacksize = 0;
$tagqueue = '';
$newtext = '';
// Known single-entity/self-closing tags
$single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' );
// Tags that can be immediately nested within themselves
$nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' );
// WP bug fix for comments - in case you REALLY meant to type '< !--'
$text = str_replace( '< !--', '< !--', $text );
// WP bug fix for LOVE <3 (and other situations with '<' before a number)
$text = preg_replace( '#<([0-9]{1})#', '&lt;$1', $text );
/**
* Matches supported tags.
*
* To get the pattern as a string without the comments paste into a PHP
* REPL like `php -a`.
*
* @see https://html.spec.whatwg.org/#elements-2
* @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name
*
* @example
* ~# php -a
* php > $s = [paste copied contents of expression below including parentheses];
* php > echo $s;
*/
$tag_pattern = (
'#<' . // Start with an opening bracket.
'(/?)' . // Group 1 - If it's a closing tag it'll have a leading slash.
'(' . // Group 2 - Tag name.
// Custom element tags have more lenient rules than HTML tag names.
'(?:[a-z](?:[a-z0-9._]*)-(?:[a-z0-9._-]+)+)' .
'|' .
// Traditional tag rules approximate HTML tag names.
'(?:[\w:]+)' .
')' .
'(?:' .
// We either immediately close the tag with its '>' and have nothing here.
'\s*' .
'(/?)' . // Group 3 - "attributes" for empty tag.
'|' .
// Or we must start with space characters to separate the tag name from the attributes (or whitespace).
'(\s+)' . // Group 4 - Pre-attribute whitespace.
'([^>]*)' . // Group 5 - Attributes.
')' .
'>#' // End with a closing bracket.
);
while ( preg_match( $tag_pattern, $text, $regex ) ) {
$full_match = $regex[0];
$has_leading_slash = ! empty( $regex[1] );
$tag_name = $regex[2];
$tag = strtolower( $tag_name );
$is_single_tag = in_array( $tag, $single_tags, true );
$pre_attribute_ws = isset( $regex[4] ) ? $regex[4] : '';
$attributes = trim( isset( $regex[5] ) ? $regex[5] : $regex[3] );
$has_self_closer = '/' === substr( $attributes, -1 );
$newtext .= $tagqueue;
$i = strpos( $text, $full_match );
$l = strlen( $full_match );
// Clear the shifter.
$tagqueue = '';
if ( $has_leading_slash ) { // End Tag.
// If too many closing tags.
if ( $stacksize <= 0 ) {
$tag = '';
// Or close to be safe $tag = '/' . $tag.
// If stacktop value = tag close value, then pop.
} elseif ( $tagstack[ $stacksize - 1 ] === $tag ) { // Found closing tag.
$tag = '</' . $tag . '>'; // Close Tag.
array_pop( $tagstack );
$stacksize--;
} else { // Closing tag not at top, search for it.
for ( $j = $stacksize - 1; $j >= 0; $j-- ) {
if ( $tagstack[ $j ] === $tag ) {
// Add tag to tagqueue.
for ( $k = $stacksize - 1; $k >= $j; $k-- ) {
$tagqueue .= '</' . array_pop( $tagstack ) . '>';
$stacksize--;
}
break;
}
}
$tag = '';
}
} else { // Begin Tag.
if ( $has_self_closer ) { // If it presents itself as a self-closing tag...
// ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and
// immediately close it with a closing tag (the tag will encapsulate no text as a result)
if ( ! $is_single_tag ) {
$attributes = trim( substr( $attributes, 0, -1 ) ) . "></$tag";
}
} elseif ( $is_single_tag ) { // ElseIf it's a known single-entity tag but it doesn't close itself, do so
$pre_attribute_ws = ' ';
$attributes .= 0 < strlen( $attributes ) ? ' /' : '/'; // EDIT: If there are attributes, add space before closing tag to match how WP insert br, hr and img tags.
} else { // It's not a single-entity tag.
// If the top of the stack is the same as the tag we want to push, close previous tag.
if ( $stacksize > 0 && ! in_array( $tag, $nestable_tags, true ) && $tagstack[ $stacksize - 1 ] === $tag ) {
$tagqueue = '</' . array_pop( $tagstack ) . '>';
$stacksize--;
}
$stacksize = array_push( $tagstack, $tag );
}
// Attributes.
if ( $has_self_closer && $is_single_tag ) {
// We need some space - avoid <br/> and prefer <br />.
$pre_attribute_ws = ' ';
}
$tag = '<' . $tag . $pre_attribute_ws . $attributes . '>';
// If already queuing a close tag, then put this tag on too.
if ( ! empty( $tagqueue ) ) {
$tagqueue .= $tag;
$tag = '';
}
}
$newtext .= substr( $text, 0, $i ) . $tag;
$text = substr( $text, $i + $l );
}
// Clear Tag Queue.
$newtext .= $tagqueue;
// Add remaining text.
$newtext .= $text;
while ( $x = array_pop( $tagstack ) ) {
$newtext .= '</' . $x . '>'; // Add remaining tags to close.
}
// WP fix for the bug with HTML comments.
$newtext = str_replace( '< !--', '<!--', $newtext );
$newtext = str_replace( '< !--', '< !--', $newtext );
return $newtext;
}
/**
* Multibyte substr_replace(). The mbstring library does not come with a multibyte equivalent of substr_replace().
* This function behaves exactly like substr_replace() even when the arguments are arrays.
*
* @link https://gist.github.com/stemar/8287074
*
* @since 2.0
*
* @param $string
* @param $replacement
* @param $start
* @param null $length
*
* @return array|string
*/
if ( ! function_exists( __NAMESPACE__ . '\mb_substr_replace' ) ) :
function mb_substr_replace( $string, $replacement, $start, $length = null ) {
if ( is_array( $string ) ) {
$num = count( $string );
// $replacement
$replacement = is_array( $replacement ) ? array_slice( $replacement, 0, $num ) : array_pad( array( $replacement ), $num, $replacement );
// $start
if ( is_array( $start ) ) {
$start = array_slice( $start, 0, $num );
foreach ( $start as $key => $value ) {
$start[ $key ] = is_int( $value ) ? $value : 0;
}
} else {
$start = array_pad( array( $start ), $num, $start );
}
// $length
if ( ! isset( $length ) ) {
$length = array_fill( 0, $num, 0 );
} elseif ( is_array( $length ) ) {
$length = array_slice( $length, 0, $num );
foreach ( $length as $key => $value ) {
$length[ $key ] = isset( $value ) ? ( is_int( $value ) ? $value : $num ) : 0;
}
} else {
$length = array_pad( array( $length ), $num, $length );
}
// Recursive call
return array_map( __FUNCTION__, $string, $replacement, $start, $length );
}
preg_match_all( '/./us', (string) $string, $smatches );
preg_match_all( '/./us', (string) $replacement, $rmatches );
if ( $length === null ) {
$length = mb_strlen( $string );
}
array_splice( $smatches[0], $start, $length, $rmatches[0] );
return join( $smatches[0] );
}
endif;
/**
* Returns a string with all items from the $find array replaced with their matching
* items in the $replace array. This does a one to one replacement (rather than globally).
*
* This function is multibyte safe.
*
* $find and $replace are arrays, $string is the haystack. All variables are passed by reference.
*
* @since 1.0
*
* @param bool $find
* @param bool $replace
* @param string $string
*
* @return mixed|string
*/
if ( ! function_exists( __NAMESPACE__ . '\mb_find_replace' ) ) :
function mb_find_replace( &$find = false, &$replace = false, &$string = '' ) {
if ( is_array( $find ) && is_array( $replace ) && $string ) {
// check if multibyte strings are supported
if ( function_exists( 'mb_strpos' ) ) {
for ( $i = 0; $i < count( $find ); $i ++ ) {
$needle = $find[ $i ];
$start = mb_strpos( $string, $needle );
// If heading can not be found, let try decoding entities to see if it can be found.
if ( false === $start ) {
$needle = html_entity_decode(
$needle,
ENT_QUOTES,
get_option( 'blog_charset' )
);
$umlauts = false;
$umlauts = apply_filters( 'eztoc_modify_umlauts', $umlauts );
if($umlauts){
$string = html_entity_decode(
$string,
ENT_QUOTES,
get_option( 'blog_charset' )
);
}
$needle = str_replace(array('','“','”'), array('\'','"','"'), $needle);
$start = mb_strpos( $string, $needle );
}
/*
* `mb_strpos()` can return `false`. Only process `mb_substr_replace()` if position in string is found.
*/
if ( is_int( $start ) ) {
$length = mb_strlen( $needle );
$apply_new_function = apply_filters('eztoc_mb_subtr_replace',false,$string, $replace[ $i ], $start, $length);
$string = $apply_new_function?$apply_new_function:mb_substr_replace( $string, $replace[ $i ], $start, $length );
}
}
} else {
for ( $i = 0; $i < count( $find ); $i ++ ) {
$start = strpos( $string, $find[ $i ] );
$length = strlen( $find[ $i ] );
/*
* `strpos()` can return `false`. Only process `substr_replace()` if position in string is found.
*/
if ( is_int( $start ) ) {
$string = substr_replace( $string, $replace[ $i ], $start, $length );
}
}
}
}
return $string;
}
endif;
if( ! function_exists( __NAMESPACE__ . '\insertElementByPTag' ) ):
/**
* insertElementByPTag Method
*
* @since 2.0.36
* @param $content
* @param $toc
* @return false|string
* @throws \DOMException
*/
function insertElementByPTag($content, $toc)
{
$find = array('</p>');
$replace = array('</p>' . $toc);
return mb_find_replace( $find, $replace, $content );
}
endif;
if( ! function_exists( __NAMESPACE__ . '\insertElementByImgTag' ) ):
/**
* insertElementByImgTag Method
*
* @since 2.0.60
* @param $content
* @param $toc
* @return false|string
* @throws \DOMException
*/
function insertElementByImgTag($content, $toc)
{
$find = array('</figure>');
$replace = array('</figure>' . $toc);
return mb_find_replace( $find, $replace, $content );
}
endif;

View File

@ -0,0 +1,502 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Get the current post's TOC list or supplied post's TOC list.
*
* @access public
* @since 2.0
*
* @param int|null|WP_Post $post An instance of WP_Post or post ID. Defaults to current post.
* @param bool $apply_content_filter Whether or not to apply `the_content` filter when processing post for headings.
*
* @return string
*/
function get_ez_toc_list( $post = null, $apply_content_filter = true ) {
if ( ! $post instanceof WP_Post ) {
$post = get_post( $post );
}
if ( $apply_content_filter ) {
$ezPost = new ezTOC_Post( $post );
} else {
$ezPost = new ezTOC_Post( $post, false );
}
return $ezPost->getTOCList();
}
/**
* Display the current post's TOC list or supplied post's TOC list.
*
* @access public
* @since 2.0
*
* @param null|WP_Post $post An instance of WP_Post
* @param bool $apply_content_filter Whether or not to apply `the_content` filter when processing post for headings.
*/
function ez_toc_list( $post = null, $apply_content_filter = true ) {
echo get_ez_toc_list( $post, $apply_content_filter );
}
/**
* Get the current post's TOC content block or supplied post's TOC content block.
*
* @access public
* @since 2.0
*
* @param int|null|WP_Post $post An instance of WP_Post or post ID. Defaults to current post.
* @param bool $apply_content_filter Whether or not to apply `the_content` filter when processing post for headings.
*
* @return string
*/
function get_ez_toc_block( $post = null, $apply_content_filter = true ) {
if ( ! $post instanceof WP_Post ) {
$post = get_post( $post );
}
if ( $apply_content_filter ) {
$ezPost = new ezTOC_Post( $post );
} else {
$ezPost = new ezTOC_Post( $post, false );
}
return $ezPost->getTOC();
}
/**
* Display the current post's TOC content or supplied post's TOC content.
*
* @access public
* @since 2.0
*
* @param null|WP_Post $post An instance of WP_Post
* @param bool $apply_content_filter Whether or not to apply `the_content` filter when processing post for headings.
*/
function ez_toc_block( $post = null, $apply_content_filter = true ) {
echo get_ez_toc_block( $post, $apply_content_filter );
}
// Non amp checker
if ( ! function_exists('ez_toc_is_amp_activated') ){
function ez_toc_is_amp_activated() {
$result = false;
if (is_plugin_active('accelerated-mobile-pages/accelerated-moblie-pages.php') || is_plugin_active('amp/amp.php') ||
is_plugin_active('better-amp/better-amp.php') ||
is_plugin_active('wp-amp/wp-amp.php') ||
is_plugin_active('amp-wp/amp-wp.php') ||
is_plugin_active('bunyad-amp/bunyad-amp.php') )
$result = true;
return $result;
}
}
// Non amp checker
if ( ! function_exists('ez_toc_non_amp') ) {
function ez_toc_non_amp() {
$non_amp = true;
if( function_exists('ampforwp_is_amp_endpoint') && @ampforwp_is_amp_endpoint() ) {
$non_amp = false;
}
if( function_exists('is_amp_endpoint') && @is_amp_endpoint() ){
$non_amp = false;
}
if( function_exists('is_better_amp') && @is_better_amp() ){
$non_amp = false;
}
if( function_exists('is_amp_wp') && @is_amp_wp() ){
$non_amp = false;
}
return $non_amp;
}
}
/**
* MBString Extension Admin Notice
* if not loaded then msg to user
* @since 2.0.47
*/
if ( function_exists('extension_loaded') && extension_loaded('mbstring') == false ) {
function ez_toc_admin_notice_for_mbstring_extension() {
echo '<div class="notice notice-error is-not-dismissible"><p>' . esc_html__( 'PHP MBString Extension is not enabled in your php setup, please enabled to work perfectly', 'easy-table-of-contents' ) . ' <strong>' . esc_html__( 'Easy Table of Contents', 'easy-table-of-contents' ) . '</strong>. ' . esc_html__( 'Check official doc:', 'easy-table-of-contents' ). ' <a href="https://www.php.net/manual/en/mbstring.installation.php" target="_blank">' . esc_html__( 'PHP Manual', 'easy-table-of-contents' ) .'</a></p></div>';
}
add_action('admin_notices', 'ez_toc_admin_notice_for_mbstring_extension');
}
/**
* EzPrintR method
* to print_r content with pre tags
* @since 2.0.34
* @param $content
* @return void
*/
function EzPrintR($content){
echo "<pre>";
print_r($content);
echo "</pre>";
}
/**
* EzDumper method
* to var_dump content with pre tags
* @since 2.0.34
* @param $content
* @return void
*/
function EzDumper($content){
echo "<pre>";
var_dump($content);
echo "</pre>";
}
/**
* Since version 2.0.52
* Export all settings to json file
*/
add_action( 'wp_ajax_ez_toc_export_all_settings', 'ez_toc_export_all_settings');
function ez_toc_export_all_settings()
{
if ( !current_user_can( 'manage_options' ) ) {
die('-1');
}
if(!isset($_GET['_wpnonce'])){
die('-1');
}
if( !wp_verify_nonce( $_GET['_wpnonce'] , '_wpnonce' ) ){
die('-1');
}
$export_settings_data = get_option('ez-toc-settings');
if(!empty($export_settings_data)){
header('Content-type: application/json');
header('Content-disposition: attachment; filename=ez_toc_settings_backup.json');
echo json_encode($export_settings_data);
}
wp_die();
}
/**
* Adding page/post title in TOC list
* @since 2.0.56
*/
add_action( 'init', function() {
if(ezTOC_Option::get('show_title_in_toc') == 1 && !is_admin())
{
ob_start();
}
} );
add_action('shutdown', function() {
if(ezTOC_Option::get('show_title_in_toc') == 1 && !is_admin()){
$final = '';
$levels = ob_get_level();
for ($i = 0; $i < $levels; $i++) {
$final .= ob_get_clean();
}
echo apply_filters('eztoc_wordpress_final_output', $final);
}
}, 10);
add_filter('eztoc_wordpress_final_output', function($content){
if(!is_singular('post') && !is_page()) { return $content;}
if(ezTOC_Option::get('show_title_in_toc') == 1 && !is_admin()){
return preg_replace_callback(
'/<h1(.*?)>(.*?)<\/h1>/i',
function ($matches) {
$title = $matches[2];
$added_link ='<h1'.$matches[1].'><span class="ez-toc-section" id="'.esc_attr(ezTOCGenerateHeadingIDFromTitle($title)).'" ez-toc-data-id="#'.esc_attr(ezTOCGenerateHeadingIDFromTitle($title)).'"></span>';
$added_link .= esc_attr($title);
$added_link .= '<span class="ez-toc-section-end"></span></h1>';
return $added_link;
},
$content
);
}
}, 10, 1);
add_filter( 'ez_toc_modify_process_page_content', 'ez_toc_page_content_include_page_title', 10, 1 );
function ez_toc_page_content_include_page_title( $content ) {
if(ezTOC_Option::get('show_title_in_toc') == 1 && !is_admin()){
$title = get_the_title();
$added_page_title= '<h1 class="entry-title">'.wp_kses_post($title).'</h1>';
$content = $added_page_title.$content;
}
return $content;
}
function ezTOCGenerateHeadingIDFromTitle( $heading ) {
$return = false;
if ( $heading ) {
$heading = apply_filters( 'ez_toc_url_anchor_target_before', $heading );
$return = html_entity_decode( $heading, ENT_QUOTES, get_option( 'blog_charset' ) );
$return = trim( strip_tags( $return ) );
$return = remove_accents( $return );
$return = str_replace( array( "\r", "\n", "\n\r", "\r\n" ), ' ', $return );
$return = htmlentities2( $return );
$return = str_replace( array( '&amp;', '&nbsp;'), ' ', $return );
$return = str_replace( array( '&shy;' ),'', $return ); // removed silent hypen
$return = html_entity_decode( $return, ENT_QUOTES, get_option( 'blog_charset' ) );
$return = preg_replace( '/[\x00-\x1F\x7F]*/u', '', $return );
$return = str_replace(
array( '*', '\'', '(', ')', ';', '@', '&', '=', '+', '$', ',', '/', '?', '#', '[', ']' ),
'',
$return
);
$return = str_replace(
array( '%', '{', '}', '|', '\\', '^', '~', '[', ']', '`' ),
'',
$return
);
$return = str_replace(
array( '$', '.', '+', '!', '*', '\'', '(', ')', ',', '' ),
'',
$return
);
$return = str_replace(
array( '-', '-', '–', '—' ),
'-',
$return
);
$return = str_replace(
array( '‘', '’', '“', '”' ),
'',
$return
);
$return = str_replace( array( ':' ), '_', $return );
$return = preg_replace( '/\s+/', '_', $return );
$return = preg_replace( '/-+/', '-', $return );
$return = preg_replace( '/_+/', '_', $return );
$return = rtrim( $return, '-_' );
$return = preg_replace_callback(
"{[^0-9a-z_.!~*'();,/?:@&=+$#-]}i",
function( $m ) {
return sprintf( '%%%02X', ord( $m[0] ) );
},
$return
);
if ( ezTOC_Option::get( 'lowercase' ) ) {
$return = strtolower( $return );
}
if ( !$return || true == ezTOC_Option::get( 'all_fragment_prefix' ) ) {
$return = ( ezTOC_Option::get( 'fragment_prefix' ) ) ? ezTOC_Option::get( 'fragment_prefix' ) : '_';
}
if ( ezTOC_Option::get( 'hyphenate' ) ) {
$return = str_replace( '_', '-', $return );
$return = preg_replace( '/-+/', '-', $return );
}
}
return apply_filters( 'ez_toc_url_anchor_target', $return, $heading );
}
//Device Eligibility
//@since 2.0.60
function ez_toc_auto_device_target_status(){
$status = true;
if(ezTOC_Option::get( 'device_target' ) == 'mobile'){
if(function_exists('wp_is_mobile') && wp_is_mobile()){
$status = true;
}else{
$status = false;
}
}
if(ezTOC_Option::get( 'device_target' ) == 'desktop'){
if(function_exists('wp_is_mobile') && wp_is_mobile()){
$status = false;
}else{
$status = true;
}
}
return $status;
}
/**
* Check for the enable support of sticky toc/toggle
* @since 2.0.60
*/
function ez_toc_stikcy_enable_support_status(){
$status = false;
$stickyPostTypes = apply_filters('ez_toc_sticky_post_types', ezTOC_Option::get('sticky-post-types'));
if(!empty($stickyPostTypes)){
if(is_singular()){
$postType = get_post_type();
if(in_array($postType,$stickyPostTypes)){
$status = true;
}
}
}
if(ezTOC_Option::get('sticky_include_homepage')){
if ( is_front_page() ) {
$status = true;
}
}
if(ezTOC_Option::get('sticky_include_category')){
if ( is_category() ) {
$status = true;
}
}
if(ezTOC_Option::get('sticky_include_tag')){
if ( is_tag() ) {
$status = true;
}
}
if(ezTOC_Option::get('sticky_include_product_category')){
if ( is_tax( 'product_cat' ) ) {
$status = true;
}
}
if(ezTOC_Option::get('sticky_include_custom_tax')){
if ( is_tax() ) {
$status = true;
}
}
//Device Eligibility
//@since 2.0.60
if(ezTOC_Option::get( 'sticky_device_target' ) == 'mobile'){
if(function_exists('wp_is_mobile') && wp_is_mobile()){
$status = true;
}else{
$status = false;
}
}
if(ezTOC_Option::get( 'sticky_device_target' ) == 'desktop'){
if(function_exists('wp_is_mobile') && wp_is_mobile()){
$status = false;
}else{
$status = true;
}
}
return apply_filters('ez_toc_sticky_enable_support', $status);
}
/**
* Helps exclude blockquote
* @since 2.0.58
*/
if(!function_exists('ez_toc_para_blockquote_replace')){
function ez_toc_para_blockquote_replace($blockquotes, $content, $step){
$bId = 0;
if($step == 1){
foreach($blockquotes[0] as $blockquote){
$replace = '#eztocbq' . $bId . '#';
$content = str_replace( trim($blockquote), $replace, $content );
$bId++;
}
}elseif($step == 2){
foreach($blockquotes[0] as $blockquote){
$search = '#eztocbq' . $bId . '#';
$content = str_replace( $search, trim($blockquote), $content );
$bId++;
}
}
return $content;
}
}
/**
* Helps allow line breaks
* @since 2.0.59
*/
add_filter('ez_toc_title_allowable_tags', 'ez_toc_link_allow_br_tag');
function ez_toc_link_allow_br_tag($tags){
if(ezTOC_Option::get( 'prsrv_line_brk' )){
$tags = '<br>';
}
return $tags;
}
/**
* Check the status of shortcode enable support which is defined in shortcode attributes
* @since 2.0.59
*/
function ez_toc_shortcode_enable_support_status($atts){
$status = true;
if(isset($atts['post_types'])){
$exp_post_types = explode(',', $atts['post_types']);
if(!empty($exp_post_types)){
$exp_post_types = array_map("trim",$exp_post_types);
if(is_singular()){
$curr_post_type = get_post_type();
if(in_array($curr_post_type, $exp_post_types )){
$status = true;
}else{
$status = false;
}
}else{
$status = false;
}
}
}
if(isset($atts['post_in'])){
$exp_post_ids = explode(',', $atts['post_in']);
if(!empty($exp_post_ids)){
$exp_post_ids = array_map("trim",$exp_post_ids);
if(is_singular()){
$ID = get_the_ID();
if(in_array($ID, $exp_post_ids )){
$status = true;
}else{
$status = false;
}
}else{
$status = false;
}
}
}
if(isset($atts['device_target']) && $atts['device_target'] != ''){
$status = false;
$my_device = $atts['device_target'];
if(function_exists('wp_is_mobile') && wp_is_mobile()){
if($my_device == 'mobile'){
$status = true;
}
}else{
if($my_device == 'desktop'){
$status = true;
}
}
}
return $status;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,139 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class eztoc_pointers {
const DISPLAY_VERSION = 'v1.0';
function __construct () {
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
}
function admin_enqueue_scripts () {
$dismissed = explode (',', get_user_meta (wp_get_current_user ()->ID, 'dismissed_wp_pointers', true));
$do_tour = !in_array ('eztoc_subscribe_pointer', $dismissed);
if ($do_tour) {
wp_enqueue_style ('wp-pointer');
wp_enqueue_script ('wp-pointer');
add_action('admin_print_footer_scripts', array($this, 'admin_print_footer_scripts'));
add_action('admin_head', array($this, 'admin_head')); // Hook to admin head
}
}
function admin_head () {
?>
<style media="screen"> #pointer-primary { margin: 0 5px 0 0; } </style>
<?php }
function admin_print_footer_scripts () {
global $pagenow;
global $current_user;
$tour = array ();
$tab = isset($_GET['tab']) ? sanitize_text_field( wp_unslash($_GET['tab'])) : '';
$function = '';
$button2 = '';
$options = array ();
$show_pointer = false;
if (!array_key_exists($tab, $tour)) {
$show_pointer = true;
$file_error = true;
$id = '.settings_page_table-of-contents'; // Define ID used on page html element where we want to display pointer
$content = '<h3>' . sprintf (esc_html__('Thank You for using Easy TOC!', 'easy-table-of-contents'), self::DISPLAY_VERSION) . '</h3>';
$content .= '<p>' . esc_html__('Do you want the latest update on', 'easy-table-of-contents') . '<b>' . esc_html__(' Easy TOC ', 'easy-table-of-contents') . '</b>' . esc_html__('before others and some best resources on Easy TOC in a single email? - Free just for users of Easy TOC!', 'easy-table-of-contents').'</p>';
$content .= '
<style>
.wp-pointer-buttons{ padding:0; overflow: hidden; }
.wp-pointer-content .button-secondary{ left: -25px;background: transparent;top: 5px; border: 0;position: relative; padding: 0; box-shadow: none;margin: 0;color: #0085ba;} .wp-pointer-content .button-primary{ display:none} #mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
</style>
<div id="mc_embed_signup">
<form method="POST" id="subscribe-newsletter-form">
<div id="mc_embed_signup_scroll">
<div class="mc-field-group" style=" margin-left: 15px; width: 195px; float: left;">
<input type="text" name="name" class="form-control" placeholder="Name" hidden value="' . esc_attr( $current_user->display_name ) . '" style="display:none">
<input type="text" value="' . esc_attr( $current_user->user_email ) . '" name="email" class="form-control" placeholder="Email*" style=" width: 180px; padding: 6px 5px;">
<input type="text" name="company" class="form-control" placeholder="Website" hidden style=" display:none; width: 168px; padding: 6px 5px;" value="' . esc_url( get_home_url() ) . '">
<input type="hidden" name="ml-submit" value="1" />
</div>
<div id="mce-responses">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_a631df13442f19caede5a5baf_c9a71edce6" tabindex="-1" value=""></div>
<input type="submit" value="Subscribe" name="subscribe" id="pointer-close" class="button mc-newsletter-sent" style=" background: #0085ba; border-color: #006799; padding: 0px 16px; text-shadow: 0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799; height: 30px; margin-top: 1px; color: #fff; box-shadow: 0 1px 0 #006799;">
</div>
</form>
</div>';
$options = array (
'content' => $content,
'position' => array ('edge' => 'left', 'align' => 'left')
);
}
if ($show_pointer) {
$this->eztoc_pointer_script ($id, $options, esc_html__('No Thanks', 'easy-table-of-contents'), $button2, $function);
}
}
function get_admin_url($page, $tab) {
$url = admin_url();
$url .= $page.'?tab='.$tab;
return $url;
}
function eztoc_pointer_script ($id, $options, $button1, $button2=false, $function='') {
?>
<script>
(function ($) {
var wp_pointers_tour_opts = <?php echo json_encode ($options); ?>, setup;
wp_pointers_tour_opts = $.extend (wp_pointers_tour_opts, {
buttons: function (event, t) {
button= jQuery ('<a id="pointer-close" class="button-secondary">' + '<?php echo wp_kses_post($button1); ?>' + '</a>');
button_2= jQuery ('#pointer-close.button');
button.bind ('click.pointer', function () {
t.element.pointer ('close');
});
button_2.on('click', function() {
t.element.pointer ('close');
} );
return button;
},
close: function () {
$.post (ajaxurl, {
pointer: 'eztoc_subscribe_pointer',
action: 'dismiss-wp-pointer'
});
}
});
setup = function () {
$('<?php echo esc_attr($id); ?>').pointer(wp_pointers_tour_opts).pointer('open');
<?php if ($button2) { ?>
jQuery ('#pointer-close').after ('<a id="pointer-primary" class="button-primary">' + '<?php echo wp_kses_post($button2); ?>' + '</a>');
jQuery ('#pointer-primary').click (function () {
<?php echo $function; ?>
});
jQuery ('#pointer-close').click (function () {
$.post (ajaxurl, {
pointer: 'eztoc_subscribe_pointer',
action: 'dismiss-wp-pointer'
});
})
<?php } ?>
};
if (wp_pointers_tour_opts.position && wp_pointers_tour_opts.position.defer_loading) {
$(window).bind('load.wp-pointers', setup);
}
else {
setup ();
}
}) (jQuery);
</script>
<?php
}
}
$eztoc_pointers = new eztoc_pointers();
?>

File diff suppressed because it is too large Load Diff