Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/accordions-wp/admin/class-accordion-metabox.php
+++ b/accordions-wp/admin/class-accordion-metabox.php
@@ -0,0 +1,817 @@
+<?php
+/**
+ * Custom Metabox Class for Accordion Items & Settings.
+ * Handles legacy CMB2 multi-row conversion, dynamic field parsing, limits, and styling options.
+ *
+ * @package TCAccordion
+ * @version 3.0.7
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+class TCAccordion_Metabox {
+
+ /**
+ * Meta key used for storing accordion items in postmeta.
+ *
+ * @var string
+ */
+ const META_KEY = 'custom_accordion_wordpresspro_columns';
+
+ /**
+ * Maximum allowed accordion items for Free users.
+ *
+ * @var int
+ */
+ const FREE_MAX_ITEMS = 5;
+
+ /**
+ * Maximum allowed accordion items for Pro users.
+ *
+ * @var int
+ */
+ const PRO_MAX_ITEMS = 25;
+
+ /**
+ * Constructor to register hooks.
+ */
+ public function __construct() {
+ add_action( 'init', array( $this, 'register_post_type' ), 0 );
+ add_action( 'add_meta_boxes', array( $this, 'register_metabox' ) );
+ add_action( 'save_post_accordion_tp', array( $this, 'save_metabox' ), 10, 2 );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
+
+ // Admin Columns & Shortcode Notice
+ add_filter( 'manage_accordion_tp_posts_columns', array( $this, 'register_admin_columns' ) );
+ add_action( 'manage_accordion_tp_posts_custom_column', array( $this, 'render_admin_columns' ), 10, 2 );
+ add_action( 'edit_form_after_title', array( $this, 'render_shortcode_section' ) );
+
+ add_action( 'wp_ajax_tcaccordion_get_live_preview', array( $this, 'ajax_render_live_preview' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_preview_styles' ) );
+
+ add_filter( 'enter_title_here', array( $this, 'tcaccordion_change_title_placeholder' ) );
+ }
+
+ /**
+ * Register Custom Post Type
+ */
+ public function register_post_type() {
+ $labels = array(
+ 'name' => _x( 'Accordions', 'Post Type General Name', 'tcaccordion' ),
+ 'singular_name' => _x( 'Accordion', 'Post Type Singular Name', 'tcaccordion' ),
+ 'menu_name' => __( 'Accordion', 'tcaccordion' ),
+ 'name_admin_bar' => __( 'Accordion', 'tcaccordion' ),
+ 'all_items' => __( 'All Accordions', 'tcaccordion' ),
+ 'add_new_item' => __( 'Add New Accordion', 'tcaccordion' ),
+ 'add_new' => __( 'Add New Accordion', 'tcaccordion' ),
+ 'new_item' => __( 'New Item Accordion', 'tcaccordion' ),
+ 'edit_item' => __( 'Edit Accordion', 'tcaccordion' ),
+ 'update_item' => __( 'Update Accordion', 'tcaccordion' ),
+ 'view_item' => __( 'View Accordion', 'tcaccordion' ),
+ 'search_items' => __( 'Search Accordion', 'tcaccordion' ),
+ 'not_found' => __( 'Accordion Not found', 'tcaccordion' ),
+ 'not_found_in_trash' => __( 'Accordion Not found in Trash', 'tcaccordion' ),
+ );
+
+ $args = array(
+ 'label' => __( 'Accordion', 'tcaccordion' ),
+ 'description' => __( 'Accordion Post Type', 'tcaccordion' ),
+ 'labels' => $labels,
+ 'supports' => array( 'title' ),
+ 'menu_icon' => defined( 'TCACCORDION_PLUGIN_URL' ) ? TCACCORDION_PLUGIN_URL . 'assets/css/accordion.png' : 'dashicons-list-view',
+ 'hierarchical' => false,
+ 'public' => true,
+ 'show_ui' => true,
+ 'show_in_menu' => true,
+ 'show_in_nav_menus' => true,
+ 'can_export' => true,
+ 'has_archive' => true,
+ 'exclude_from_search' => false,
+ 'publicly_queryable' => true,
+ 'capability_type' => 'page',
+ );
+
+ register_post_type( 'accordion_tp', $args );
+ }
+
+ /**
+ * Check if the plugin is in Pro version.
+ *
+ * @return bool
+ */
+ private function is_pro() {
+ return false;
+ }
+
+ /**
+ * Get the maximum item limit based on user license.
+ *
+ * @return int
+ */
+ private function get_max_items() {
+ return $this->is_pro() ? self::PRO_MAX_ITEMS : self::FREE_MAX_ITEMS;
+ }
+
+ /**
+ * Register the Accordion metabox wrapper.
+ *
+ * @return void
+ */
+ public function register_metabox() {
+ add_meta_box(
+ 'custom_accordion_wordpress_feature',
+ __( 'Accordion Control Panel', 'tcaccordion' ),
+ array( $this, 'render_metabox_wrapper' ),
+ 'accordion_tp',
+ 'normal',
+ 'high'
+ );
+ }
+
+ /**
+ * Enqueue admin scripts and styles.
+ *
+ * @param string $hook Current admin page hook.
+ * @return void
+ */
+ public function enqueue_assets( $hook ) {
+ global $post_type;
+
+ if ( 'accordion_tp' !== $post_type ) {
+ return;
+ }
+
+ wp_enqueue_style( 'wp-color-picker' );
+ wp_enqueue_script( 'wp-color-picker' );
+
+ wp_enqueue_style(
+ 'tcaccordion-metabox',
+ TCACCORDION_PLUGIN_URL . 'admin/css/accordion-metabox.css',
+ array(),
+ '3.0.7'
+ );
+
+ wp_enqueue_script( 'jquery-ui-sortable' );
+ wp_enqueue_editor();
+
+ wp_enqueue_style( 'wp-color-picker' );
+
+ wp_enqueue_script(
+ 'tcaccordion-color-picker',
+ TCACCORDION_PLUGIN_URL . 'admin/js/color-picker.js',
+ array( 'wp-color-picker' ),
+ TCACCORDION_VERSION,
+ true
+ );
+
+ wp_enqueue_script(
+ 'tcaccordion-metabox',
+ TCACCORDION_PLUGIN_URL . 'admin/js/accordion-metabox.js',
+ array( 'jquery', 'jquery-ui-sortable' ),
+ '3.0.7',
+ true
+ );
+
+ wp_localize_script(
+ 'tcaccordion-metabox',
+ 'tcAccordion',
+ array(
+ 'maxItems' => $this->get_max_items(),
+ 'isPro' => $this->is_pro(),
+ 'addText' => __( 'Add Item', 'tcaccordion' ),
+ 'removeText' => __( 'Remove', 'tcaccordion' ),
+ 'limitText' => sprintf( __( 'Free version is limited to %d items.', 'tcaccordion' ), self::FREE_MAX_ITEMS ),
+ )
+ );
+ }
+
+ /**
+ * Main Tabbed Container Wrapper
+ */
+ public function render_metabox_wrapper( $post ) {
+ wp_nonce_field( 'tcaccordion_save_action', 'tcaccordion_nonce_field' );
+
+ // Retrieve active tab from meta or default to '#tab-accordion-content'
+ $active_tab = get_post_meta( $post->ID, '_tc_active_tab', true );
+ if ( empty( $active_tab ) ) {
+ $active_tab = '#tab-accordion-content';
+ }
+ ?>
+ <div id="tc-tabs-container" class="tc-tabs-container">
+ <!-- Hidden input to post the current active tab -->
+ <input type="hidden" id="tc_active_tab_input" name="tc_active_tab_input" value="<?php echo esc_attr( $active_tab ); ?>" />
+
+ <ul class="tc-tabs-menu">
+ <li class="tc-tab-item <?php echo ( '#tab-accordion-content' === $active_tab ) ? 'current' : ''; ?>">
+ <a href="#tab-accordion-content" class="tc-tab-link">
+ <span class="dashicons dashicons-editor-justify"></span>
+ <?php esc_html_e( 'Accordion Content', 'tcaccordion' ); ?>
+ </a>
+ </li>
+ <li class="tc-tab-item <?php echo ( '#tab-accordion-settings' === $active_tab ) ? 'current' : ''; ?>">
+ <a href="#tab-accordion-settings" class="tc-tab-link">
+ <span class="dashicons dashicons-admin-generic"></span>
+ <?php esc_html_e( 'Accordion Settings', 'tcaccordion' ); ?>
+ </a>
+ </li>
+
+ <li class="tc-tab-item <?php echo ( '#tab-accordion-preview' === $active_tab ) ? 'current' : ''; ?>">
+ <a href="#tab-accordion-preview" class="tc-tab-link">
+ <span class="dashicons dashicons-visibility"></span>
+ <?php esc_html_e( 'Live Preview', 'tcaccordion' ); ?>
+ </a>
+ </li>
+ </ul>
+
+ <div class="tc-tab-wrapper">
+ <!-- TAB 1: REPEATER / GROUP FIELDS -->
+ <div id="tab-accordion-content" class="tc-tab-content <?php echo ( '#tab-accordion-content' === $active_tab ) ? 'active' : ''; ?>">
+ <?php $this->render_accordion_content_tab( $post ); ?>
+ </div>
+
+ <!-- TAB 2: STYLING & OPTIONS -->
+ <div id="tab-accordion-settings" class="tc-tab-content <?php echo ( '#tab-accordion-settings' === $active_tab ) ? 'active' : ''; ?>">
+ <?php $this->render_accordion_settings_tab( $post ); ?>
+ </div>
+
+ <!-- TAB 3: LIVE PREVIEW TAB -->
+<div id="tab-accordion-preview" class="tc-tab-content <?php echo ( '#tab-accordion-preview' === $active_tab ) ? 'active' : ''; ?>">
+ <div class="tc-preview-tab-container" style="padding: 20px; background: #fff; border: 1px solid #c3c4c7; border-radius: 4px;">
+ <div class="tc-preview-header" style="margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center;">
+ <div>
+ <h3 style="margin: 0; display: inline-block;">
+ <span class="dashicons dashicons-visibility" style="vertical-align: middle;"></span>
+ <?php esc_html_e( 'Exact Frontend Live Preview', 'tcaccordion' ); ?>
+ </h3>
+ <span class="description" style="margin-left: 10px;">
+ <?php esc_html_e( '(Renders full shortcodes, embeds, and actual frontend CSS)', 'tcaccordion' ); ?>
+ </span>
+ </div>
+ <button type="button" id="tc-refresh-preview-btn" class="button button-secondary">
+ <span class="dashicons dashicons-update" style="vertical-align: middle; line-height: 1.3;"></span>
+ <?php esc_html_e( 'Refresh Preview', 'tcaccordion' ); ?>
+ </button>
+ </div>
+
+ <!-- Preview Loader & Display Canvas -->
+ <div id="tc-preview-loading" style="display: none; padding: 30px; text-align: center;">
+ <span class="spinner is-active" style="float: none; margin: 0 5px 0 0;"></span>
+ <?php esc_html_e( 'Rendering exact frontend preview...', 'tcaccordion' ); ?>
+ </div>
+
+ <div id="tc-exact-preview-canvas" class="tc-frontend-preview-wrap">
+ <!-- Exact Frontend HTML loaded here via AJAX -->
+ </div>
+ </div>
+</div>
+ </div>
+ </div>
+ <?php
+ }
+
+ /**
+ * Tab 1 Render: Repeater Items Markup
+ */
+ private function render_accordion_content_tab( $post ) {
+ $items = $this->get_items_from_db( $post->ID );
+ $max_limit = $this->get_max_items();
+ ?>
+ <div id="tcaccordion-wrapper">
+ <div id="tcaccordion-sortable">
+ <?php
+ if ( ! empty( $items ) && is_array( $items ) ) {
+ foreach ( $items as $index => $item ) {
+ $this->render_item( $index, $item );
+ }
+ }
+ ?>
+ </div>
+
+ <p class="tcaccordion-actions">
+ <button type="button" class="button button-primary" id="tcaccordion-add" <?php echo count( $items ) >= $max_limit ? 'disabled="disabled"' : ''; ?>>
+ <?php esc_html_e( 'Add Accordion Item', 'tcaccordion' ); ?>
+ </button>
+ </p>
+
+ <?php if ( ! $this->is_pro() ) : ?>
+ <p class="description tcaccordion-limit-notice">
+ <?php
+ printf(
+ /* translators: %d: maximum number of items */
+ esc_html__( 'Free version is limited to %d items. Upgrade to Pro for unlimited items.', 'tcaccordion' ),
+ self::FREE_MAX_ITEMS
+ );
+ ?>
+ </p>
+ <?php endif; ?>
+ </div>
+
+ <script type="text/template" id="tcaccordion-template">
+ <?php
+ ob_start();
+ $this->render_item(
+ '__INDEX__',
+ array(
+ 'title' => '',
+ 'description' => '',
+ )
+ );
+ $template_content = ob_get_clean();
+ echo str_replace( array( '<script', '</script>' ), array( '<script', '</script' ), $template_content );
+ ?>
+ </script>
+ <?php
+ }
+
+ /**
+ * Tab 2 Render: Settings & Theme Picker Controls
+ */
+ private function render_accordion_settings_tab( $post ) {
+ // Meta Values Retrieve
+ $custom_accordion_columns_post_themes = get_post_meta( $post->ID, 'custom_accordion_columns_post_themes', true );
+ $custom_accordion_title_bg_color = get_post_meta( $post->ID, 'custom_accordion_title_bg_color', true );
+ $custom_accordion_title_font_color = get_post_meta( $post->ID, 'custom_accordion_title_font_color', true );
+ $custom_accordion_title_font_size = get_post_meta( $post->ID, 'custom_accordion_title_font_size', true );
+ $custom_accordion_content_bg_color = get_post_meta( $post->ID, 'custom_accordion_content_bg_color', true );
+ $custom_accordion_content_font_color = get_post_meta( $post->ID, 'custom_accordion_content_font_color', true );
+ $custom_accordion_content_font_size = get_post_meta( $post->ID, 'custom_accordion_content_font_size', true );
+ $custom_accordion_content_padding = get_post_meta( $post->ID, 'custom_accordion_content_padding', true );
+ $_tpaccpro_wiki_acc_themes_title_position = get_post_meta( $post->ID, '_tpaccpro_wiki_acc_themes_title_position', true );
+ $_tpaccpro_wiki_acc_themes_show_hide_icons = get_post_meta( $post->ID, '_tpaccpro_wiki_acc_themes_show_hide_icons', true );
+ $_tpaccpro_wiki_acc_themes_icon_position = get_post_meta( $post->ID, '_tpaccpro_wiki_acc_themes_icon_position', true );
+ $_tpaccpro_wiki_acc_theme_content_margin = get_post_meta( $post->ID, '_tpaccpro_wiki_acc_theme_content_margin', true );
+ $custom_accordion_title_line_height = get_post_meta( $post->ID, 'custom_accordion_title_line_height', true );
+ $custom_accordion_content_line_height = get_post_meta( $post->ID, 'custom_accordion_content_line_height', true );
+ $custom_accordion_content_letter_spacing = get_post_meta( $post->ID, 'custom_accordion_content_letter_spacing', true );
+
+ if ( empty( $custom_accordion_columns_post_themes ) ) {
+ $custom_accordion_columns_post_themes = 'theme1';
+ }
+
+ $themes = array(
+ 'theme1' => array( 'label' => __( 'Sun Flower', 'tcaccordion' ), 'img' => 'theme1.png' ),
+ 'theme2' => array( 'label' => __( 'Orange', 'tcaccordion' ), 'img' => 'theme2.png' ),
+ 'theme3' => array( 'label' => __( 'Pumpkin', 'tcaccordion' ), 'img' => 'theme3.png' ),
+ 'theme4' => array( 'label' => __( 'Alizarin', 'tcaccordion' ), 'img' => 'theme4.png' ),
+ 'theme5' => array( 'label' => __( 'Carrot', 'tcaccordion' ), 'img' => 'theme5.png' ),
+ );
+ ?>
+<table class="form-table tc-settings-table">
+ <tr valign="top">
+ <th scope="row"><label><?php esc_html_e( 'Accordion Themes', 'tcaccordion' ); ?></label></th>
+ <td>
+ <div class="tc-theme-picker">
+ <?php foreach ( $themes as $key => $theme ) : ?>
+ <?php $img_url = defined( 'TCACCORDION_PLUGIN_URL' ) ? TCACCORDION_PLUGIN_URL . 'admin/images/' . $theme['img'] : ''; ?>
+ <label class="tc-theme-option">
+ <input type="radio" name="custom_accordion_columns_post_themes" value="<?php echo esc_attr( $key ); ?>" <?php checked( $custom_accordion_columns_post_themes, $key ); ?> />
+ <div class="tc-theme-card">
+ <?php if ( $img_url ) : ?>
+ <img src="<?php echo esc_url( $img_url ); ?>" alt="<?php echo esc_attr( $theme['label'] ); ?>" />
+ <?php endif; ?>
+ <span><?php echo esc_html( $theme['label'] ); ?></span>
+ </div>
+ </label>
+ <?php endforeach; ?>
+ </div>
+ </td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom-accordion-title-bg-color"><?php esc_html_e( 'Title BG Color', 'tcaccordion' ); ?></label></th>
+ <td><input name="custom_accordion_title_bg_color" class="tc-color-field" id="custom-accordion-title-bg-color" type="text" value="<?php echo esc_attr( $custom_accordion_title_bg_color ); ?>" /></td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom-accordion-title-font-color"><?php esc_html_e( 'Title Font Color', 'tcaccordion' ); ?></label></th>
+ <td><input name="custom_accordion_title_font_color" class="tc-color-field" id="custom-accordion-title-font-color" type="text" value="<?php echo esc_attr( $custom_accordion_title_font_color ); ?>" /></td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom_accordion_title_font_size"><?php esc_html_e( 'Title Font Size', 'tcaccordion' ); ?></label></th>
+ <td><input type="number" name="custom_accordion_title_font_size" id="custom_accordion_title_font_size" min="10" max="45" value="<?php echo ! empty( $custom_accordion_title_font_size ) ? esc_attr( $custom_accordion_title_font_size ) : '15'; ?>"> px</td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom_accordion_title_line_height"><?php esc_html_e( 'Title Line Height', 'tcaccordion' ); ?></label></th>
+ <td><input type="number" step="0.1" name="custom_accordion_title_line_height" id="custom_accordion_title_line_height" min="0.8" max="3" value="<?php echo ! empty( $custom_accordion_title_line_height ) ? esc_attr( $custom_accordion_title_line_height ) : '1.4'; ?>"> (e.g. 1.4)</td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="_tpaccpro_wiki_acc_themes_title_position"><?php esc_html_e( 'Title Text Position', 'tcaccordion' ); ?></label></th>
+ <td>
+ <select name="_tpaccpro_wiki_acc_themes_title_position" id="_tpaccpro_wiki_acc_themes_title_position">
+ <option value="left" <?php selected( $_tpaccpro_wiki_acc_themes_title_position, 'left' ); ?>><?php esc_html_e( 'Left', 'tcaccordion' ); ?></option>
+ <option value="center" <?php selected( $_tpaccpro_wiki_acc_themes_title_position, 'center' ); ?>><?php esc_html_e( 'Center', 'tcaccordion' ); ?></option>
+ <option value="right" <?php selected( $_tpaccpro_wiki_acc_themes_title_position, 'right' ); ?>><?php esc_html_e( 'Right', 'tcaccordion' ); ?></option>
+ </select>
+ </td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="_tpaccpro_wiki_acc_themes_show_hide_icons"><?php esc_html_e( 'Show/Hide Icon', 'tcaccordion' ); ?></label></th>
+ <td>
+ <select name="_tpaccpro_wiki_acc_themes_show_hide_icons" id="_tpaccpro_wiki_acc_themes_show_hide_icons">
+ <option value="1" <?php selected( $_tpaccpro_wiki_acc_themes_show_hide_icons, '1' ); ?>><?php esc_html_e( 'Show', 'tcaccordion' ); ?></option>
+ <option value="2" <?php selected( $_tpaccpro_wiki_acc_themes_show_hide_icons, '2' ); ?>><?php esc_html_e( 'Hide', 'tcaccordion' ); ?></option>
+ </select>
+ </td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="_tpaccpro_wiki_acc_themes_icon_position"><?php esc_html_e( 'Icon Position', 'tcaccordion' ); ?></label></th>
+ <td>
+ <select name="_tpaccpro_wiki_acc_themes_icon_position" id="_tpaccpro_wiki_acc_themes_icon_position">
+ <option value="1" <?php selected( $_tpaccpro_wiki_acc_themes_icon_position, '1' ); ?>><?php esc_html_e( 'Left', 'tcaccordion' ); ?></option>
+ <option value="2" <?php selected( $_tpaccpro_wiki_acc_themes_icon_position, '2' ); ?>><?php esc_html_e( 'Right', 'tcaccordion' ); ?></option>
+ </select>
+ </td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom-accordion-content-bg-color"><?php esc_html_e( 'Content BG Color', 'tcaccordion' ); ?></label></th>
+ <td><input name="custom_accordion_content_bg_color" class="tc-color-field" id="custom-accordion-content-bg-color" type="text" value="<?php echo esc_attr( $custom_accordion_content_bg_color ); ?>" /></td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom-accordion-content-font-color"><?php esc_html_e( 'Content Font Color', 'tcaccordion' ); ?></label></th>
+ <td><input name="custom_accordion_content_font_color" class="tc-color-field" id="custom-accordion-content-font-color" type="text" value="<?php echo esc_attr( $custom_accordion_content_font_color ); ?>" /></td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom_accordion_content_font_size"><?php esc_html_e( 'Content Font Size', 'tcaccordion' ); ?></label></th>
+ <td><input type="number" name="custom_accordion_content_font_size" id="custom_accordion_content_font_size" min="10" max="45" value="<?php echo ! empty( $custom_accordion_content_font_size ) ? esc_attr( $custom_accordion_content_font_size ) : '14'; ?>"> px</td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom_accordion_content_line_height"><?php esc_html_e( 'Content Line Height', 'tcaccordion' ); ?></label></th>
+ <td><input type="number" step="0.1" name="custom_accordion_content_line_height" id="custom_accordion_content_line_height" min="0.8" max="3" value="<?php echo ! empty( $custom_accordion_content_line_height ) ? esc_attr( $custom_accordion_content_line_height ) : '1.6'; ?>"> (e.g. 1.6)</td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom_accordion_content_letter_spacing"><?php esc_html_e( 'Content Letter Spacing', 'tcaccordion' ); ?></label></th>
+ <td><input type="number" step="0.1" name="custom_accordion_content_letter_spacing" id="custom_accordion_content_letter_spacing" min="0" max="10" value="<?php echo ! empty( $custom_accordion_content_letter_spacing ) ? esc_attr( $custom_accordion_content_letter_spacing ) : '0'; ?>"> px</td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="_tpaccpro_wiki_acc_theme_content_margin"><?php esc_html_e( 'Margin Between Accordion', 'tcaccordion' ); ?></label></th>
+ <td><input type="number" name="_tpaccpro_wiki_acc_theme_content_margin" id="_tpaccpro_wiki_acc_theme_content_margin" min="0" max="45" value="<?php echo ! empty( $_tpaccpro_wiki_acc_theme_content_margin ) ? esc_attr( $_tpaccpro_wiki_acc_theme_content_margin ) : '5'; ?>"> px</td>
+ </tr>
+
+ <tr valign="top">
+ <th scope="row"><label for="custom_accordion_content_padding"><?php esc_html_e( 'Content Padding', 'tcaccordion' ); ?></label></th>
+ <td><input type="number" name="custom_accordion_content_padding" id="custom_accordion_content_padding" min="0" max="45" value="<?php echo ! empty( $custom_accordion_content_padding ) ? esc_attr( $custom_accordion_content_padding ) : '12'; ?>"> px</td>
+ </tr>
+ </table>
+ <?php
+ }
+
+ /**
+ * Universal Meta Parser: Fetches all postmeta rows and flattens both CMB2 legacy entries and array formats.
+ *
+ * @param int $post_id Post ID.
+ * @return array Standardized array of items.
+ */
+ private function get_items_from_db( $post_id ) {
+ $all_meta_rows = get_post_meta( $post_id, self::META_KEY, false );
+ $items = array();
+
+ if ( empty( $all_meta_rows ) || ! is_array( $all_meta_rows ) ) {
+ return $items;
+ }
+
+ foreach ( $all_meta_rows as $row ) {
+ if ( ! is_array( $row ) ) {
+ continue;
+ }
+
+ if ( isset( $row[0] ) && is_array( $row[0] ) ) {
+ foreach ( $row as $sub_item ) {
+ if ( is_array( $sub_item ) ) {
+ $item = $this->extract_item_fields( $sub_item );
+ if ( $item ) {
+ $items[] = $item;
+ }
+ }
+ }
+ } else {
+ $item = $this->extract_item_fields( $row );
+ if ( $item ) {
+ $items[] = $item;
+ }
+ }
+ }
+
+ return $items;
+ }
+
+ /**
+ * Extract title and description from multiple legacy field key variants.
+ *
+ * @param array $data Raw array row.
+ * @return array|false Formatted item or false if empty.
+ */
+ private function extract_item_fields( $data ) {
+ $title = '';
+ if ( isset( $data['title'] ) ) {
+ $title = $data['title'];
+ } elseif ( isset( $data['custom_accordions_pro_title'] ) ) {
+ $title = $data['custom_accordions_pro_title'];
+ }
+
+ $details = '';
+ if ( isset( $data['description'] ) ) {
+ $details = $data['description'];
+ } elseif ( isset( $data['custom_accordions_pro_details'] ) ) {
+ $details = $data['custom_accordions_pro_details'];
+ }
+
+ if ( '' !== $title || '' !== $details ) {
+ return array(
+ 'title' => $title,
+ 'description' => $details,
+ );
+ }
+
+ return false;
+ }
+
+ /**
+ * Render Individual Item Markup.
+ *
+ * @param string|int $index Index key.
+ * @param array $item Item details.
+ * @return void
+ */
+ private function render_item( $index, $item ) {
+ $title = isset( $item['title'] ) ? $item['title'] : '';
+ $content = isset( $item['description'] ) ? $item['description'] : '';
+
+ $editor_id = 'tcaccordion_editor_' . sanitize_html_class( $index );
+ ?>
+
+ <div class="tcaccordion-item">
+ <div class="tcaccordion-header">
+ <span class="dashicons dashicons-menu"></span>
+ <strong class="tcaccordion-label">
+ <?php echo esc_html( $title ? $title : __( 'New Accordion', 'tcaccordion' ) ); ?>
+ </strong>
+ <button type="button" class="button-link tcaccordion-toggle">
+ <span class="dashicons dashicons-arrow-down-alt2"></span>
+ </button>
+ </div>
+
+ <div class="tcaccordion-body">
+ <p>
+ <label><strong><?php esc_html_e( 'Accordion Title', 'tcaccordion' ); ?></strong></label>
+ <input
+ type="text"
+ class="widefat tcaccordion-title"
+ name="<?php echo esc_attr( self::META_KEY ); ?>[<?php echo esc_attr( $index ); ?>][title]"
+ value="<?php echo esc_attr( $title ); ?>"
+ >
+ </p>
+
+ <p>
+ <label><strong><?php esc_html_e( 'Description', 'tcaccordion' ); ?></strong></label>
+ <?php
+ wp_editor(
+ $content,
+ $editor_id,
+ array(
+ 'textarea_name' => self::META_KEY . '[' . $index . '][description]',
+ 'textarea_rows' => 6,
+ 'media_buttons' => false,
+ 'teeny' => true,
+ 'quicktags' => true,
+ )
+ );
+ ?>
+ </p>
+
+ <p>
+ <button type="button" class="button tcaccordion-remove">
+ <?php esc_html_e( 'Remove', 'tcaccordion' ); ?>
+ </button>
+ </p>
+ </div>
+ </div>
+ <?php
+ }
+
+ /**
+ * Combined Save Handler (Group Fields + Style Settings)
+ *
+ * @param int $post_id Post ID.
+ * @param WP_Post $post Post Object.
+ * @return void
+ */
+ public function save_metabox( $post_id, $post ) {
+ if (
+ ! isset( $_POST['tcaccordion_nonce_field'] ) ||
+ ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['tcaccordion_nonce_field'] ) ), 'tcaccordion_save_action' )
+ ) {
+ return;
+ }
+
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || wp_is_post_revision( $post_id ) ) {
+ return;
+ }
+
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
+ return;
+ }
+
+ // 1. SAVE REPEATER / GROUP ITEMS
+ if ( empty( $_POST[ self::META_KEY ] ) || ! is_array( $_POST[ self::META_KEY ] ) ) {
+ delete_post_meta( $post_id, self::META_KEY );
+ } else {
+ $items = array();
+ $max_limit = $this->get_max_items();
+ $raw_posted_items = wp_unslash( $_POST[ self::META_KEY ] );
+
+ foreach ( array_values( $raw_posted_items ) as $item ) {
+ if ( ! is_array( $item ) ) {
+ continue;
+ }
+
+ if ( count( $items ) >= $max_limit ) {
+ break;
+ }
+
+ $title = isset( $item['title'] ) ? sanitize_text_field( $item['title'] ) : '';
+ $details = isset( $item['description'] ) ? wp_kses_post( $item['description'] ) : '';
+
+ if ( '' !== $title || '' !== $details ) {
+ $items[] = array(
+ 'title' => $title,
+ 'description' => $details,
+ );
+ }
+ }
+
+ delete_post_meta( $post_id, self::META_KEY );
+ if ( ! empty( $items ) ) {
+ update_post_meta( $post_id, self::META_KEY, $items );
+ }
+ }
+
+ // Save Active Tab State
+ if ( isset( $_POST['tc_active_tab_input'] ) ) {
+ $active_tab = sanitize_text_field( wp_unslash( $_POST['tc_active_tab_input'] ) );
+ update_post_meta( $post_id, '_tc_active_tab', $active_tab );
+ }
+
+ // 2. SAVE ACCORDION STYLE & OPTION METAS
+ $style_fields = array(
+ 'custom_accordion_columns_post_themes' => 'sanitize_text_field',
+ 'custom_accordion_title_font_size' => 'sanitize_text_field',
+ 'custom_accordion_content_font_size' => 'sanitize_text_field',
+ 'custom_accordion_content_padding' => 'sanitize_text_field',
+ '_tpaccpro_wiki_acc_themes_title_position' => 'sanitize_text_field',
+ '_tpaccpro_wiki_acc_themes_show_hide_icons' => 'sanitize_text_field',
+ '_tpaccpro_wiki_acc_themes_icon_position' => 'sanitize_text_field',
+ '_tpaccpro_wiki_acc_theme_content_margin' => 'sanitize_text_field',
+ 'custom_accordion_title_line_height' => 'sanitize_text_field',
+ 'custom_accordion_content_line_height' => 'sanitize_text_field',
+ 'custom_accordion_content_letter_spacing' => 'sanitize_text_field',
+ 'custom_accordion_title_bg_color' => 'sanitize_hex_color',
+ 'custom_accordion_title_font_color' => 'sanitize_hex_color',
+ 'custom_accordion_content_bg_color' => 'sanitize_hex_color',
+ 'custom_accordion_content_font_color' => 'sanitize_hex_color',
+ );
+
+ foreach ( $style_fields as $field => $sanitize_callback ) {
+ if ( isset( $_POST[ $field ] ) ) {
+ $val = call_user_func( $sanitize_callback, $_POST[ $field ] );
+ update_post_meta( $post_id, $field, $val );
+ }
+ }
+ }
+
+ /**
+ * Custom Admin Post Columns
+ */
+ public function register_admin_columns( $columns ) {
+ return array(
+ 'cb' => '<input type="checkbox" />',
+ 'title' => __( 'Shortcode Name', 'tcaccordion' ),
+ 'shortcode' => __( 'Shortcode', 'tcaccordion' ),
+ 'doshortcode' => __( 'Template Shortcode', 'tcaccordion' ),
+ 'date' => __( 'Date', 'tcaccordion' ),
+ );
+ }
+
+ /**
+ * Display Admin Post Columns Content
+ */
+ public function render_admin_columns( $column, $post_id ) {
+ if ( 'shortcode' === $column ) {
+ echo '<input style="background:#ddd" type="text" readonly onClick="this.select();" value="[tcpaccordion id="' . esc_attr( $post_id ) . '"]" />';
+ }
+ if ( 'doshortcode' === $column ) {
+ echo '<textarea cols="40" rows="2" style="background:#ddd;" readonly onClick="this.select();"><?php echo do_shortcode("[tcpaccordion id='' . esc_attr( $post_id ) . '']"); ?></textarea>';
+ }
+ }
+
+ /**
+ * Display Shortcode Notice Below Title Input
+ */
+ public function render_shortcode_section( $post ) {
+ if ( 'accordion_tp' !== $post->post_type ) {
+ return;
+ }
+
+ $shortcode = "[tcpaccordion id='" . $post->ID . "']";
+ $php_code = '<?php echo do_shortcode("[tcpaccordion id=' . $post->ID . ']"); ?>';
+ ?>
+ <div style="padding: 15px; border: 1px solid #ddd; background: #f9f9f9; margin-top: 15px;">
+ <div style="display: flex; gap: 20px;">
+ <div style="width: 50%;">
+ <p><strong><?php esc_html_e( 'Shortcode', 'tcaccordion' ); ?>:</strong> <span id="tc-sc-notice" style="color: green; display: none; margin-left: 10px;"><?php esc_html_e( 'Copied!', 'tcaccordion' ); ?></span></p>
+ <input type="text" style="width:100%; cursor:pointer;" value="<?php echo esc_attr( $shortcode ); ?>" readonly onclick="tcCopyNotice(this, 'tc-sc-notice')" />
+ </div>
+ <div style="width: 50%;">
+ <p><strong><?php esc_html_e( 'PHP Code', 'tcaccordion' ); ?>:</strong> <span id="tc-php-notice" style="color: green; display: none; margin-left: 10px;"><?php esc_html_e( 'Copied!', 'tcaccordion' ); ?></span></p>
+ <input type="text" style="width:100%; cursor:pointer;" value="<?php echo esc_attr( $php_code ); ?>" readonly onclick="tcCopyNotice(this, 'tc-php-notice')" />
+ </div>
+ </div>
+ </div>
+ <script>
+ function tcCopyNotice(input, noticeId) {
+ input.select();
+ navigator.clipboard.writeText(input.value);
+ var notice = document.getElementById(noticeId);
+ notice.style.display = "inline";
+ setTimeout(function() { notice.style.display = "none"; }, 2000);
+ }
+ </script>
+ <?php
+ }
+
+ /**
+ * Change Post Title Placeholder
+ */
+
+ public function tcaccordion_change_title_placeholder( $title ) {
+
+ $screen = get_current_screen();
+
+ if ( $screen && 'accordion_tp' === $screen->post_type ) {
+ return __( 'Accordion Group Title', 'tcaccordion' );
+ }
+ return $title;
+ }
+
+ /**
+ * AJAX Handler to generate exact live frontend markup from unsaved form data.
+ */
+ public function ajax_render_live_preview() {
+ check_ajax_referer( 'tcaccordion_save_action', 'security' );
+
+ if ( ! current_user_can( 'edit_posts' ) ) {
+ wp_send_json_error( array( 'message' => __( 'Permission denied.', 'tcaccordion' ) ) );
+ }
+
+ $post_id = isset( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : 0;
+
+ // Parse serialized form data string sent from JavaScript
+ $posted_meta = array();
+ if ( ! empty( $_POST['form_data'] ) ) {
+ wp_parse_str( $_POST['form_data'], $posted_meta );
+ }
+
+ // Initialize the renderer
+ $renderer = new TCAccordion_Renderer( $post_id );
+
+ // Pass live unsaved form fields to the renderer instance
+ if ( ! empty( $posted_meta ) && method_exists( $renderer, 'set_preview_data' ) ) {
+ $renderer->set_preview_data( $posted_meta );
+ }
+
+ $html = $renderer->render();
+
+ wp_send_json_success( array( 'html' => $html ) );
+ }
+
+ /**
+ * Enqueue Admin Scripts & Styles for Preview
+ */
+ public function enqueue_admin_preview_styles( $hook ) {
+ if ( 'post.php' !== $hook && 'post-new.php' !== $hook ) {
+ return;
+ }
+
+ $screen = get_current_screen();
+ if ( is_object( $screen ) && 'accordion_tp' === $screen->post_type ) {
+ wp_enqueue_style( 'tcaccordion-responsive', TCACCORDION_PLUGIN_URL . 'assets/css/responsive-accordion.css', array(), TCACCORDION_VERSION );
+ wp_enqueue_style( 'tcaccordion-style', TCACCORDION_PLUGIN_URL . 'assets/css/style.css', array(), TCACCORDION_VERSION );
+ //wp_enqueue_style( 'font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css', array(), '4.7.0' );
+ }
+ }
+
+}
+
+new TCAccordion_Metabox();
No newline at end of file
--- a/accordions-wp/admin/class-tcaccordion-admin-support.php
+++ b/accordions-wp/admin/class-tcaccordion-admin-support.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Admin Support Page Class.
+ *
+ * @package TCAccordion
+ * @subpackage TCAccordion/Admin
+ * @version 3.0.7
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+/**
+ * Handles the admin support page rendering and menu integration.
+ */
+class TCAccordion_Admin_Support {
+
+ /**
+ * Initialize hooks.
+ */
+ public function __construct() {
+ add_action( 'admin_menu', array( $this, 'register_support_page' ), 99 );
+ }
+
+ /**
+ * Register the admin submenu page under the main plugin menu.
+ *
+ * @return void
+ */
+ public function register_support_page() {
+ add_submenu_page(
+ 'edit.php?post_type=accordion_tp',
+ __( 'Support', 'tcaccordion' ),
+ __( 'Support', 'tcaccordion' ),
+ 'manage_options',
+ 'tcaccordion-support',
+ array( $this, 'render_support_page' )
+ );
+ }
+
+ /**
+ * Render the support page view.
+ *
+ * @return void
+ */
+ public function render_support_page() {
+ $view_path = plugin_dir_path( __FILE__ ) . 'views/support-page.php';
+
+ if ( file_exists( $view_path ) ) {
+ include $view_path;
+ }
+ }
+}
+
+// Instantiate class.
+new TCAccordion_Admin_Support();
No newline at end of file
--- a/accordions-wp/admin/class-tcaccordion-review-notice.php
+++ b/accordions-wp/admin/class-tcaccordion-review-notice.php
@@ -0,0 +1,157 @@
+<?php
+/**
+ * Admin Review Notice Class with AJAX Dismissal & Live Preview option.
+ *
+ * @package TCAccordion
+ * @subpackage TCAccordion/Admin
+ * @version 3.0.7
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+/**
+ * Handles review prompt display after installation threshold.
+ */
+class TCAccordion_Review_Notice {
+
+ /**
+ * Days delay before showing review prompt.
+ */
+ const DISPLAY_DELAY_DAYS = 7;
+
+ /**
+ * Option keys.
+ */
+ const DISMISSED_OPTION = 'tcaccordion_review_notice_dismissed';
+
+ /**
+ * Initialize hooks.
+ */
+ public function __construct() {
+ add_action( 'admin_notices', array( $this, 'display_review_notice' ) );
+ add_action( 'wp_ajax_tcaccordion_dismiss_review_notice', array( $this, 'ajax_dismiss_notice' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
+ }
+
+ /**
+ * Check eligibility and render admin notice banner.
+ *
+ * @return void
+ */
+ public function display_review_notice() {
+ if ( ! current_user_can( 'manage_options' ) ) {
+ return;
+ }
+
+ // Check if notice dismissed or preview requested
+ $is_dismissed = get_option( self::DISMISSED_OPTION, false );
+ $is_preview = isset( $_GET['tcaccordion_preview_review_notice'] ) && '1' === $_GET['tcaccordion_preview_review_notice']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+
+ if ( $is_dismissed && ! $is_preview ) {
+ return;
+ }
+
+ // Check installation delay threshold
+ $installed_time = TCAccordion::get_installation_time();
+ $delay_seconds = self::DISPLAY_DELAY_DAYS * DAY_IN_SECONDS;
+
+ if ( ( time() - $installed_time < $delay_seconds ) && ! $is_preview ) {
+ return;
+ }
+
+ $review_url = 'https://wordpress.org/support/plugin/accordions-wp/reviews/#new-post';
+ ?>
+ <div id="tcaccordion-review-notice" class="notice notice-info is-dismissible tcaccordion-review-wrapper" style="padding: 15px; position: relative;">
+ <?php if ( $is_preview ) : ?>
+ <p><span class="dashicons dashicons-visibility" style="color:#d63638;"></span> <strong><?php esc_html_e( '[ADMIN PREVIEW MODE]', 'tcaccordion' ); ?></strong></p>
+ <?php endif; ?>
+
+ <h3 style="margin:0 0 8px 0;"><?php esc_html_e( 'Are you enjoying Accordion-WP?', 'tcaccordion' ); ?></h3>
+ <p style="margin:0 0 12px 0;">
+ <?php esc_html_e( 'Hope you find this plugin helpful! If you like Accordion-WP, would you mind taking a minute to rate it 5 stars on WordPress.org? Your support means a lot!', 'tcaccordion' ); ?>
+ </p>
+
+ <div class="tcaccordion-notice-actions">
+ <a href="<?php echo esc_url( $review_url ); ?>" target="_blank" rel="noopener noreferrer" class="button button-primary tcaccordion-dismiss-btn" data-type="reviewed">
+ <span class="dashicons dashicons-external" style="vertical-align: middle; line-height: 1.3;"></span>
+ <?php esc_html_e( 'Leave a Review', 'tcaccordion' ); ?>
+ </a>
+
+ <button type="button" class="button button-secondary tcaccordion-dismiss-btn" data-type="already" style="margin-left: 6px;">
+ <?php esc_html_e( 'I Already Did', 'tcaccordion' ); ?>
+ </button>
+
+ <button type="button" class="button button-link tcaccordion-dismiss-btn" data-type="later" style="margin-left: 6px; text-decoration: none;">
+ <?php esc_html_e( 'Maybe Later', 'tcaccordion' ); ?>
+ </button>
+ </div>
+ </div>
+ <?php
+ }
+
+ /**
+ * Handle AJAX dismiss submission.
+ *
+ * @return void
+ */
+ public function ajax_dismiss_notice() {
+ check_ajax_referer( 'tcaccordion_review_nonce', 'security' );
+
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error( array( 'message' => __( 'Permission denied.', 'tcaccordion' ) ) );
+ }
+
+ $dismiss_type = isset( $_POST['dismiss_type'] ) ? sanitize_key( $_POST['dismiss_type'] ) : 'dismissed';
+
+ if ( 'later' === $dismiss_type ) {
+ // Reset installation time to 7 days from now to remind later
+ update_option( TCAccordion::INSTALL_KEY, time() );
+ } else {
+ // Permanent dismissal
+ update_option( self::DISMISSED_OPTION, true );
+ }
+
+ wp_send_json_success();
+ }
+
+ /**
+ * Enqueue inline AJAX JS handler.
+ *
+ * @return void
+ */
+ public function enqueue_admin_scripts() {
+ if ( ! current_user_can( 'manage_options' ) ) {
+ return;
+ }
+
+ $script = "
+ jQuery(document).ready(function($) {
+ $(document).on('click', '.tcaccordion-dismiss-btn, #tcaccordion-review-notice .notice-dismiss', function(e) {
+ var btn = $(this);
+ var dismissType = btn.data('type') || 'dismissed';
+
+ $.post(ajaxurl, {
+ action: 'tcaccordion_dismiss_review_notice',
+ security: '" . wp_create_nonce( 'tcaccordion_review_nonce' ) . "',
+ dismiss_type: dismissType
+ }, function(response) {
+ if (response.success) {
+ $('#tcaccordion-review-notice').fadeTo(100, 0, function() {
+ $(this).slideUp(100, function() {
+ $(this).remove();
+ });
+ });
+ }
+ });
+ });
+ });
+ ";
+
+ wp_add_inline_script( 'jquery', $script );
+ }
+}
+
+// Instantiate
+new TCAccordion_Review_Notice();
No newline at end of file
--- a/accordions-wp/admin/views/support-page.php
+++ b/accordions-wp/admin/views/support-page.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Admin Support Page Template View.
+ *
+ * @package TCAccordion
+ * @subpackage TCAccordion/Admin/Views
+ * @version 3.0.7
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+?>
+
+<div class="wrap tcaccordion-admin-wrap">
+ <h1 class="wp-heading-inline team-manager-admin-support">
+ <?php esc_html_e( 'Support', 'tcaccordion' ); ?>
+ </h1>
+
+ <div class="postbox team-manager-admin-area" style="padding: 20px; margin-top: 15px;">
+ <h2 class="eddpcs-admin-hthree"><?php esc_html_e( 'Support Forum', 'tcaccordion' ); ?></h2>
+ <p>
+ <?php
+ printf(
+ /* translators: 1: WordPress.org support URL, 2: Themepoints Q&A URL */
+ esc_html__( 'If you need any help, please don't hesitate to post it on %1$s or %2$s.', 'tcaccordion' ),
+ '<a href="' . esc_url( 'https://wordpress.org/support/plugin/accordions-wp' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'WordPress.org', 'tcaccordion' ) . '</a>',
+ '<a href="' . esc_url( 'https://themepoints.com/questions-answer/' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Themepoints.com', 'tcaccordion' ) . '</a>'
+ );
+ ?>
+ </p>
+ <br />
+
+ <h2><?php esc_html_e( 'Submit a Review', 'tcaccordion' ); ?></h2>
+ <p>
+ <?php
+ printf(
+ /* translators: 1: WordPress.org plugin review URL, 2: Contact form URL */
+ esc_html__( 'We spend plenty of time developing this plugin and give it freely to make your life easier. If you like this plugin, please %1$s. If you have any problems with the plugin, please %2$s before leaving a review.', 'tcaccordion' ),
+ '<a href="' . esc_url( 'https://wordpress.org/plugins/accordions-wp/' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'rate it 5 stars', 'tcaccordion' ) . '</a>',
+ '<a href="' . esc_url( 'https://themepoints.com/contact/' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'let us know', 'tcaccordion' ) . '</a>'
+ );
+ ?>
+ </p>
+ <br />
+
+ <h2><?php esc_html_e( 'Unlock More Features', 'tcaccordion' ); ?></h2>
+ <p>
+ <?php
+ printf(
+ /* translators: 1: Premium version URL */
+ esc_html__( 'Upgrading to the %s would unlock more amazing features of this plugin.', 'tcaccordion' ),
+ '<a href="' . esc_url( 'https://themepoints.com/wp-accordions' ) . '" target="_blank" rel="noopener noreferrer"><span style="color: red; text-decoration: none;">' . esc_html__( 'Premium Version', 'tcaccordion' ) . '</span></a>'
+ );
+ ?>
+ </p>
+ </div>
+</div>
No newline at end of file
--- a/accordions-wp/custom-accordion-wp.php
+++ b/accordions-wp/custom-accordion-wp.php
@@ -1,178 +1,226 @@
<?php
- /**
- * Plugin Name: Accordion-WP
- * Plugin URI: https://themepoints.com/wp-accordions/
- * Description: Create beautiful, responsive accordions and FAQ sections with multiple styles, skins, and advanced customization—perfect for organizing content and improving UX.
- * Version: 3.0.6
- * Author: Themepoints
- * Author URI: https://themepoints.com
- * Text Domain: tcaccordion
- * License: GPLv2 or later
- */
+/**
+ * Plugin Name: Accordion-WP
+ * Plugin URI: https://themepoints.com/wp-accordions/
+ * Description: Create beautiful, responsive accordions and FAQ sections with multiple styles, skins, and advanced customization—perfect for organizing content and improving UX.
+ * Version: 3.0.7
+ * Author: Themepoints
+ * Author URI: https://themepoints.com
+ * Text Domain: tcaccordion
+ * Domain Path: /languages
+ * License: GPL v2 or later
+ *
+ * @package TCAccordion
+ */
- if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly
- }
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
- /**
- * Define plugin constants
+/**
+ * Main Plugin Bootstrap Class.
+ */
+final class TCAccordion {
+
+ /**
+ * Plugin version.
+ *
+ * @var string
*/
- define( 'TCACCORDION_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
- define( 'TCACCORDION_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
+ const VERSION = '3.0.7';
/**
- * Include required files
+ * Option key for storing the installation timestamp.
+ *
+ * @var string
*/
- require_once TCACCORDION_PLUGIN_PATH . 'metabox/custom-meta-boxes.php';
- require_once TCACCORDION_PLUGIN_PATH . 'inc/accordions-wp-post-type.php';
- require_once TCACCORDION_PLUGIN_PATH . 'theme/custom-wp-accordion-themes.php';
+ const INSTALL_KEY = 'tcaccordion_installed_time';
/**
- * Load translation for the plugin
+ * Instance of this class.
+ *
+ * @var TCAccordion|null
*/
- function custom_accordion_load_textdomain(){
- load_plugin_textdomain('tcaccordion', false, dirname( plugin_basename( __FILE__ ) ) .'/languages/' );
- }
- add_action('plugins_loaded', 'custom_accordion_load_textdomain');
+ private static $instance = null;
/**
- * Enqueue frontend scripts and styles
+ * Main TCAccordion Instance.
+ *
+ * @return TCAccordion
*/
- function custom_accordion_active_script(){
- wp_register_style( 'accordion-responsive-css', plugins_url( 'css/responsive-accordion.css' , __FILE__ ) );
- wp_register_style( 'accordion-main-css', plugins_url( 'css/style.css' , __FILE__ ) );
- wp_enqueue_script('jquery');
- wp_register_script('accordion-responsive-js', plugins_url( 'js/responsive-accordion.min.js', __FILE__ ), array('jquery'), '1.0', false);
- wp_enqueue_style('wp-color-picker');
- wp_enqueue_script('accordion-wp-color-picker', plugins_url(), array( 'wp-color-picker' ), false, true );
+ public static function instance() {
+ if ( is_null( self::$instance ) ) {
+ self::$instance = new self();
+ }
+ return self::$instance;
}
- add_action('wp_enqueue_scripts', 'custom_accordion_active_script');
/**
- * Enqueue admin scripts and styles for custom post type
+ * Private constructor to enforce Singleton pattern.
*/
- function custom_accordion_admin_enqueue_scripts(){
- global $typenow;
- if(($typenow == 'accordion_tp')){
- wp_enqueue_style( 'accordion-admin-css', plugins_url( 'admin/css/accordion-backend-admin.css' , __FILE__ ) );
- wp_enqueue_script('jquery');
- wp_enqueue_script('accordion-admin-js', plugins_url( 'admin/js/accordion-backend-admin.js', __FILE__ ), array('jquery'), '1.0', false);
- wp_enqueue_style('wp-color-picker');
- wp_enqueue_script( 'accordion_color_picker', plugins_url('admin/js/color-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
- wp_enqueue_script("jquery-ui-sortable");
- wp_enqueue_script("jquery-ui-draggable");
- wp_enqueue_script("jquery-ui-droppable");
- }
+ private function __construct() {
+ $this->define_constants();
+ $this->load_dependencies();
+ $this->init_hooks();
}
- add_action('admin_enqueue_scripts', 'custom_accordion_admin_enqueue_scripts');
/**
- * Add Pro Version Link on Plugin Page
+ * Define Plugin Constants.
+ *
+ * @return void
*/
- function tps_accordion_prover_action_links( $links ) {
- $links[] = '<a href="https://themepoints.com/wp-accordions/" style="color: red; font-weight: bold;" target="_blank">Buy Pro!</a>';
- return $links;
+ private function define_constants() {
+ define( 'TCACCORDION_VERSION', self::VERSION );
+ define( 'TCACCORDION_FILE', __FILE__ );
+ define( 'TCACCORDION_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
+ define( 'TCACCORDION_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
+ define( 'TCACCORDION_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
}
- add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'tps_accordion_prover_action_links' );
/**
- * Register Metabox
+ * Include Required Class Files.
+ *
+ * @return void
*/
- function custom_accordion_wordpress_filter_meta_box( $meta_boxes ) {
- $meta_boxes[] = array(
- 'id' => 'custom_accordion_wordpress_feature',
- 'title' => 'Accordion',
- 'pages' => array('accordion_tp'),
- 'context' => 'normal',
- 'priority' => 'high',
- 'show_names' => true,
- 'fields' => array(
- array(
- 'id' => 'custom_accordion_wordpresspro_columns',
- 'name' => 'Accordion Item Details',
- 'type' => 'group',
- 'repeatable' => true,
- 'sortable' => true,
- 'repeatable_max' => 5,
+ private function load_dependencies() {
+ // Admin Metabox Manager
+ require_once TCACCORDION_PLUGIN_PATH . 'admin/class-accordion-metabox.php';
+
+ // Admin Support Page
+ require_once TCACCORDION_PLUGIN_PATH . 'admin/class-tcaccordion-admin-support.php';
- 'fields' => array(
- array(
- 'id' => 'custom_accordions_pro_title',
- 'name' => 'Accordion Title',
- 'type' => 'text',
- 'cols' => 4
- ),
- array(
- 'id' => 'custom_accordions_pro_details',
- 'name' => 'Description',
- 'type' => 'wysiwyg',
- 'sanitization_cb' => false,
- 'options' => array( 'textarea_rows' => 8, ),
- 'default' => 'Insert Your Description Here?',
- ),
- )
- )
- )
- );
+ // Admin Review Notice
+ require_once TCACCORDION_PLUGIN_PATH . 'admin/class-tcaccordion-review-notice.php';
- return $meta_boxes;
+ // Frontend Renderer Engine
+ require_once TCACCORDION_PLUGIN_PATH . 'theme/class-tcaccordion-renderer.php';
+
+ // Shortcode Handler
+ require_once TCACCORDION_PLUGIN_PATH . 'inc/class-tcaccordion-shortcode.php';
}
- add_filter( 'cmb_meta_boxes', 'custom_accordion_wordpress_filter_meta_box' );
/**
- * Add Accordion Title Filter
+ * Register WordPress Hooks.
+ *
+ * @return void
*/
- function custom_accordion_wordpress_title( $title ){
- $screen = get_current_screen();
- if ( 'accordion_tp' == $screen->post_type ) {
- $title = 'Accordion Group Title';
- }
- return $title;
+ private function init_hooks() {
+ // Register activation hook
+ register_activation_hook( TCACCORDION_FILE, array( $this, 'activate' ) );
+
+ add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
+ add_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_assets' ) );
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
+ add_filter( 'plugin_action_links_' . TCACCORDION_PLUGIN_BASENAME, array( $this, 'add_plugin_action_links' ) );
}
- add_filter( 'enter_title_here', 'custom_accordion_wordpress_title' );
/**
- * Add Options Page
+ * Plugin Activation Callback.
+ * Sets installation timestamp if it doesn't already exist.
+ *
+ * @return void
*/
- function themepoints_custom_accordion_option_init(){
- register_setting( 'custom_accordion_options_setting', 'themepoints_accordion_theme');
- register_setting( 'custom_accordion_options_setting', 'accordion_content_font_pages');
+ public function activate() {
+ if ( ! get_option( self::INSTALL_KEY ) ) {
+ update_option( self::INSTALL_KEY, time() );
+ }
}
- add_action('admin_init', 'themepoints_custom_accordion_option_init' );
/**
- * Add Plugin Submenu Page
+ * Get the installation timestamp.
+ *
+ * @return int Timestamp in seconds.
*/
- function themepoints_custom_accordion_submenu_pages() {
- add_submenu_page( 'edit.php?post_type=accordion_tp', __('Help & Support', 'tcaccordion'), __('Help & Support', 'tcaccordion'), 'manage_options', 'support', 'themepoints_custom_accordion_support_callback' );
+ public static function get_installation_time() {
+ return (int) get_option( self::INSTALL_KEY, time() );
}
/**
- * Plugin Callback Function
+ * Load Translation Text Domain.
+ *
+ * @return void
*/
- function themepoints_custom_accordion_support_callback() {
- require_once(plugin_dir_path(__FILE__).'inc/custom-accordion-admin.php');
+ public function load_textdomain() {
+ load_plugin_textdomain(
+ 'tcaccordion',
+ false,
+ dirname( TCACCORDION_PLUGIN_BASENAME ) . '/languages'
+ );
}
- add_action('admin_menu', 'themepoints_custom_accordion_submenu_pages');
/**
- * Register Plugin Shortcode
- */
- function custom_accordion_shortcode_register($atts, $content = null){
- wp_enqueue_script( 'accordion-responsive-js' );
- wp_enqueue_style( 'accordion-responsive-css' );
- wp_enqueue_style( 'accordion-main-css' );
- $atts = shortcode_atts(
- array(
- 'id' => "",
- ), $atts
+ * Register Frontend Scripts and Styles.
+ *
+ * @return void
+ */
+ public function register_frontend_assets() {
+ wp_register_style(
+ 'tcaccordion-responsive',
+ TCACCORDION_PLUGIN_URL . 'assets/css/responsive-accordion.css',
+ array(),
+ TCACCORDION_VERSION
+ );
+
+ wp_register_style(
+ 'tcaccordion-style',
+ TCACCORDION_PLUGIN_URL . 'assets/css/style.css',
+ array(),
+ TCACCORDION_VERSION
);
- global $post;
-
- $post_id = $atts['id'];
- $content = '';
- $content.= TCP_accordions_wordpress_table_body($post_id);
- return $content;
- }// shortcode hook
- add_shortcode('tcpaccordion', 'custom_accordion_shortcode_register');
No newline at end of file
+ wp_register_script(
+ 'tcaccordion-script',
+ TCACCORDION_PLUGIN_URL . 'assets/js/responsive-accordion.min.js',
+ array( 'jquery' ),
+ TCACCORDION_VERSION,
+ true
+ );
+ }
+
+ /**
+ * Register Plugin Admin Settings.
+ *
+ * @return void
+ */
+ public function register_settings() {
+ register_setting(
+ 'custom_accordion_options_setting',
+ 'themepoints_accordion_theme'
+ );
+
+ register_setting(
+ 'custom_accordion_options_setting',
+ 'accordion_content_font_pages'
+ );
+ }
+
+ /**
+ * Add custom action links on the Plugins page.
+ *
+ * @param array $links Existing action links.
+ * @return array Modified action links.
+ */
+ public function add_plugin_action_links( $links ) {
+ $custom_links = array(
+ sprintf(
+ '<a href="%s" target="_blank" rel="noopener noreferrer" style="color:#d63638;font-weight:600;">%s</a>',
+ esc_url( 'https://themepoints.com/wp-accordions/' ),
+ esc_html__( 'Buy Pro!', 'tcaccordion' )
+ ),
+ );
+
+ return array_merge( $links, $custom_links );
+ }
+}
+
+/**
+ * Global function instance accessor.
+ *
+ * @return TCAccordion
+ */
+function tcaccordion() {
+ return TCAccordion::instance();
+}
+
+// Initialize the plugin.
+tcaccordion();
No newline at end of file
--- a/accordions-wp/inc/accordions-wp-post-type.php
+++ b/accordions-wp/inc/accordions-wp-post-type.php
@@ -1,423 +0,0 @@
-<?php
-
- if( !defined( 'ABSPATH' ) ){
- exit;
- }
-
- // Register Custom Post Type
- function custom_accordion_post_register() {
- $labels = array(
- 'name' => _x( 'Accordions', 'Post Type General Name', 'tcaccordion' ),
- 'singular_name' => _x( 'Accordion', 'Post Type Singular Name', 'tcaccordion' ),
- 'menu_name' => __( 'Accordion', 'tcaccordion' ),
- 'name_admin_bar' => __( 'Accordion', 'tcaccordion' ),
- 'archives' => __( 'Item Archives', 'tcaccordion' ),
- 'attributes' => __( 'Item Attributes', 'tcaccordion' ),
- 'parent_item_colon' => __( 'Parent Item:', 'tcaccordion' ),
- 'all_items' => __( 'All Accordions', 'tcaccordion' ),
- 'add_new_item' => __( 'Add New Accordion', 'tcaccordion' ),
- 'add_new' => __( 'Add New Accordion', 'tcaccordion' ),
- 'new_item' => __( 'New Item Accordion', 'tcaccordion' ),
- 'edit_item' => __( 'Edit Accordion', 'tcaccordion' ),
- 'update_item' => __( 'Update Accordion', 'tcaccordion' ),
- 'view_item' => __( 'View Accordion', 'tcaccordion' ),
- 'view_items' => __( 'View Accordions', 'tcaccordion' ),
- 'search_items' => __( 'Search Accordion', 'tcaccordion' ),
- 'not_found' => __( 'Accordion Not found', 'tcaccordion' ),
- 'not_found_in_trash' => __( 'Accordion Not found in Trash', 'tcaccordion' ),
- 'featured_image' => __( '', 'tcaccordion' ),
- 'set_featured_image' => __( 'Set featured image', 'tcaccordion' ),
- 'remove_featured_image' => __( 'Remove featured image', 'tcaccordion' ),
- 'use_featured_image' => __( 'Use as featured image', 'tcaccordion' ),
- 'insert_into_item' => __( 'Insert into item', 'tcaccordion' ),
- 'uploaded_to_this_item' => __( 'Uploaded to this item', 'tcaccordion' ),
- 'items_list' => __( 'Items list', 'tcaccordion' ),
- 'items_list_navigation' => __( 'Items list navigation', 'tcaccordion' ),
- 'filter_items_list' => __( 'Filter items list', 'tcaccordion' ),
- );
- $args = array(
- 'label' => __( 'Accordion', 'tcaccordion' ),
- 'description' => __( 'Accordion Post Type Description', 'tcaccordion' ),
- 'labels' => $labels,
- 'supports' => array( 'title'),
- 'menu_icon' => TCACCORDION_PLUGIN_URL.'css/accordion.png',
- 'hierarchical' => false,
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'show_in_admin_bar' => true,
- 'show_in_nav_menus' => true,
- 'can_export' => true,
- 'has_archive' => true,
- 'exclude_from_search' => false,
- 'publicly_queryable' => true,
- 'capability_type' => 'page',
- );
- register_post_type( 'accordion_tp', $args );
- }
- add_action( 'init', 'custom_accordion_post_register', 0 );
-
- /*==========================================================================
- Adds a box to the main column on the Post and Page edit screens
- ==========================================================================*/
- function custom_accordion_wordpress_add_custom_box() {
- $screens = array( 'accordion_tp' );
- foreach ( $screens as $screen ){
- add_meta_box('accordion_sectionid', __( 'Accordion Settings','tcaccordion' ),'custom_accordion_wordpress_inner_custom_box', $screen);
- }
- }
- add_action( 'add_meta_boxes', 'custom_accordion_wordpress_add_custom_box' );
-
- /*==========================================================================
- Prints the box content
- ==========================================================================*/
-
- function custom_accordion_wordpress_inner_custom_box() {
- global $post;
- // Use nonce for verification
- wp_nonce_field( plugin_basename( __FILE__ ), 'custom_accordion_wordpress_dynamicMeta_noncename' );
-
- //get the saved meta as an arry
- $custom_accordion_columns_post_themes = get_post_meta( $post->ID, 'custom_accordion_columns_post_themes', true );
- $custom_accordion_title_bg_color = get_post_meta( $post->ID, 'custom_accordion_title_bg_color', true );
- $custom_accordion_title_font_color = get_post_meta( $post->ID, 'custom_accordion_title_font_color', true );
- $custom_accordion_title_font_size = get_post_meta( $post->ID, 'custom_accordion_title_font_size', true );
- $custom_accordion_content_bg_color = get_post_meta( $post->ID, 'custom_accordion_content_bg_color', true );
- $custom_accordion_content_font_color = get_post_meta( $post->ID, 'custom_accordion_content_font_color', true );
- $custom_accordion_content_font_size = get_post_meta( $post->ID, 'custom_accordion_content_font_size', true );
- $custom_accordion_content_padding = get_post_meta( $post->ID, 'custom_accordion_content_padding', true );
- $_tpaccpro_wiki_acc_themes_title_position = get_post_meta( $post->ID, '_tpaccpro_wiki_acc_themes_title_position', true );
- $_tpaccpro_wiki_acc_themes_show_hide_icons = get_post_meta( $post->ID, '_tpaccpro_wiki_acc_themes_show_hide_icons', true );
- $_tpaccpro_wiki_acc_themes_icon_position = get_post_meta( $post->ID, '_tpaccpro_wiki_acc_themes_icon_position', true );
- $_tpaccp