Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,204 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden.
}
/**
* Class TVD_SM_Admin_Helper
*/
class TVD_SM_Admin_Helper {
/**
* The single instance of the class.
*
* @var TVD_SM_Admin_Helper singleton instance.
*/
protected static $_instance = null;
/**
* Main TVD_SM_Admin_Helper Instance.
* Ensures only one instance of TVD_SM_Admin_Helper is loaded or can be loaded.
*
* @return TVD_SM_Admin_Helper
*/
public static function instance() {
if ( static::$_instance === null ) {
static::$_instance = new self();
}
return static::$_instance;
}
/**
* Get used scripts
*
* @return array
*/
public function tvd_sm_get_scripts() {
$scripts = tah()->tvd_sm_get_option( 'global_lp_scripts', array() );
/* backward compatibility - the old status field was not an array; scripts added before the ttb integration had a boolean value */
foreach ( $scripts as $key => $script ) {
$status = $script['status'];
if ( ! is_array( $status ) ) {
$scripts[ $key ]['status'] = array(
TVD_SM_Frontend::LP_LOCATION => $status,
TVD_SM_Frontend::THEME_LOCATION => false,
);
}
/* special weird character most likey copy-pasted from a word document or smth - "long dash" */
/* SUPP-6590 - when this happens the script manager is useless - it doesn't render. Also, the LPs are blank .. */
$scripts[ $key ]['code'] = str_replace( '—', '--', $script['code'] );
}
return array_values( $scripts );
}
/**
* Get option value or add it, if this doesn't exists
*
* @param string $option_name Name of option to add. Expected to not be SQL-escaped.
* @param array $default_values options default values.
*
* @return array|mixed
*/
public function tvd_sm_get_option( $option_name, $default_values = array() ) {
$option = get_option( $option_name );
if ( empty( $option ) ) {
add_option( $option_name, $default_values );
$option = $default_values;
}
return $option;
}
/**
* returns value inside the given array, if no value is found then it returns -1
*
* @param $id
* @param $scripts
*
* @return int|string
*/
public function tvd_sm_retrieve_key_for_id( $id, $scripts ) {
foreach ( $scripts as $key => $val ) {
if ( array_search( $id, $val ) === 'id' ) {
return $key;
}
}
return $this->tvd_sm_get_last_id_plus_one( $scripts );
}
/**
* Return next if for the scripts
*
* @param $scripts
*
* @return int
*/
public function tvd_sm_get_last_id_plus_one( $scripts ) {
if ( empty( $scripts ) ) {
$id = 1;
} else {
$script = array_slice( $scripts, - 1 );
$id = $script[0]['id'] + 1;
}
return $id;
}
/**
* comparator for usort
*
* @param $a
* @param $b
*
* @return int
*/
public function sort_by_order( $a, $b ) {
if ( $a['order'] === $b['order'] ) {
return 0;
}
return ( $a['order'] > $b['order'] ) ? 1 : - 1;
}
/**
* Wrapper over the update option
*
* @param string $option_name Option name.
* @param mixed $value Option value.
*
* @return array|mixed
*/
public function tvd_sm_update_option( $option_name, $value ) {
/* allow only specific options to be saved */
if ( empty( $option_name ) || ! in_array( $option_name, [ 'global_lp_scripts' ] ) ) {
return false;
}
$old_value = $this->tvd_sm_get_option( $option_name );
/* Check to see if the old value is the same as the new one */
if ( is_array( $old_value ) && is_array( $value ) ) {
$diff = $this->array_diff_assoc_recursive( $old_value, $value ) + $this->array_diff_assoc_recursive( $value, $old_value );
} elseif ( is_object( $old_value ) && is_object( $value ) ) {
$diff = array_diff_assoc( get_object_vars( $old_value ), get_object_vars( $value ) ) + array_diff_assoc( get_object_vars( $value ), get_object_vars( $old_value ) );
} else {
$diff = ! ( $old_value === $value );
}
/* If the new value is the same with the old one, return true and don't update */
if ( empty( $diff ) ) {
return true;
}
return update_option( $option_name, $value );
}
/**
* The recursive version of the array_diff_assoc taken from php.net
*
* @param $array1
* @param $array2
*
* @return array
*/
public function array_diff_assoc_recursive( $array1, $array2 ) {
$difference = array();
foreach ( $array1 as $key => $value ) {
if ( is_array( $value ) ) {
if ( ! isset( $array2[ $key ] ) || ! is_array( $array2[ $key ] ) ) {
$difference[ $key ] = $value;
} else {
$new_diff = $this->array_diff_assoc_recursive( $value, $array2[ $key ] );
if ( ! empty( $new_diff ) ) {
$difference[ $key ] = $new_diff;
}
}
} elseif ( ! array_key_exists( $key, $array2 ) || $array2[ $key ] !== $value ) {
$difference[ $key ] = $value;
}
}
return $difference;
}
}
/**
* @return TVD_SM_Admin_Helper
*/
function tah() {
return TVD_SM_Admin_Helper::instance();
}
tah();

View File

@@ -0,0 +1,123 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden.
}
/**
* Class TVD_SM_Admin
*/
class TVD_SM_Admin {
public function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'init', array( $this, 'init' ) );
add_action( 'current_screen', array( $this, 'conditional_hooks' ) );
}
public function includes() {
include_once 'class-tvd-sm-rest-scripts-controller.php';
}
public function hooks() {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'rest_api_init', array( $this, 'admin_create_rest_routes' ) );
}
public function init() {
$this->includes();
$this->hooks();
}
public function enqueue_scripts() {
if ( tve_get_current_screen_key() === 'admin_page_tve_dash_script_manager' ) {
tve_dash_enqueue();
tve_dash_enqueue_style( 'tvd-sm-admin-css', TVD_SM_Constants::url( '/assets/css/admin.css' ) );
tve_dash_enqueue_script( 'tvd-sm-admin-js', TVD_SM_Constants::url( 'assets/js/dist/admin.min.js' ), array(
'tve-dash-main-js',
'jquery',
'jquery-ui-sortable',
'backbone',
), false, true );
$params = array(
'routes' => array(
'scripts' => get_rest_url() . 'script-manager/v1/scripts',
'scripts_order' => get_rest_url() . 'script-manager/v1/scripts-order',
'clear_page_level_scripts' => get_rest_url() . 'script-manager/v1/clear-old-scripts',
),
'is_ttb_active' => TVD_SM_Constants::is_ttb_active(),
'is_tar_active' => TVD_SM_Constants::is_architect_active(),
'nonce' => wp_create_nonce( 'wp_rest' ),
'scripts' => tah()->tvd_sm_get_scripts(),
'script_placement_text' => array(
TVD_SM_Constants::HEAD_PLACEMENT => 'Before ' . htmlentities( '</head>' ),
TVD_SM_Constants::BODY_OPEN_PLACEMENT => 'After ' . htmlentities( '<body>' ),
TVD_SM_Constants::BODY_CLOSE_PLACEMENT => 'Before ' . htmlentities( '</body>' ),
),
'translations' => include TVD_SM_Constants::path( 'includes/i18n.php' ),
'dash_url' => admin_url( 'admin.php?page=tve_dash_section' ),
'url' => TVD_SM_Constants::url(),
'recognized_scripts' => array(
'keywords' => TVD_SM_Constants::get_recognized_scripts_keywords(),
'data' => TVD_SM_Constants::get_recognized_scripts_data(),
),
);
wp_localize_script( 'tvd-sm-admin-js', 'TVD_SM_CONST', $params );
}
}
/**
* Hook based on the current screen
*/
public function conditional_hooks() {
/**
* if screen = script_manager feature then load all the templates for the SM admin side
*/
if ( tve_get_current_screen_key() === 'admin_page_tve_dash_script_manager' ) {
add_action( 'admin_print_scripts', array( $this, 'admin_backbone_templates' ), 9 );
add_filter( 'admin_title', array( $this, 'change_title' ) );
}
}
public function change_title( $title ) {
return __( 'Script Manager', 'thrive-dash' ) . $title;
}
/**
* Add page to admin menu so the page could be accessed
*/
public function admin_menu() {
add_submenu_page( '', __( 'Landing Pages Analytics & Scripts', 'thrive-dash' ), __( 'Landing Pages Analytics & Scripts', 'thrive-dash' ), 'manage_options', 'tve_dash_script_manager', array(
$this,
'admin_dashboard',
) );
}
/**
* Main TVD_SM page content
*/
public function admin_dashboard() {
include TVD_SM_Constants::path( 'includes/admin/views/dashboard.php' );
}
public function admin_create_rest_routes() {
$controller = new TVD_SM_REST_Scripts_Controller();
$controller->register_routes();
}
/**
* Add templates as scripts in the footer.
*/
public function admin_backbone_templates() {
$templates = tve_dash_get_backbone_templates( TVD_SM_Constants::path( 'includes/admin/views/templates' ), 'templates' );
tve_dash_output_backbone_templates( $templates );
}
}
return new TVD_SM_Admin();

View File

@@ -0,0 +1,179 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
class TVD_SM_REST_Scripts_Controller {
public $version = 1;
public $namespace = 'script-manager/v';
public function register_routes() {
register_rest_route( $this->namespace . $this->version, '/' . 'scripts', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_scripts' ),
'permission_callback' => array( $this, 'general_permissions_check' ),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_scripts' ),
'permission_callback' => array( $this, 'general_permissions_check' ),
),
) );
register_rest_route( $this->namespace . $this->version, '/' . 'scripts-order', array(
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'order_scripts' ),
'permission_callback' => array( $this, 'general_permissions_check' ),
),
) );
register_rest_route( $this->namespace . $this->version, '/' . 'clear-old-scripts', array(
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'clear_individual_scripts' ),
'permission_callback' => array( $this, 'general_permissions_check' ),
),
) );
register_rest_route( $this->namespace . $this->version, '/scripts/(?P<id>[\d]+)', array(
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_scripts' ),
'permission_callback' => array( $this, 'general_permissions_check' ),
),
array(
'methods' => WP_REST_Server::DELETABLE,
'callback' => array( $this, 'delete_script' ),
'permission_callback' => array( $this, 'general_permissions_check' ),
),
) );
}
/**
*
* Clears the scripts added individually to landing pages.
*
* @return WP_REST_Response
*/
public function clear_individual_scripts() {
foreach ( get_pages( array( 'meta_key' => 'tve_landing_page' ) ) as $page ) {
update_post_meta( $page->ID, 'tve_global_scripts', array( 'head' => '', 'footer' => '' ) );
}
return new WP_REST_Response( 1, 200 );
}
/**
* Return scripts - calls get_scripts from the Admin Helper class
*
* @return WP_Error|WP_REST_Response
*/
public function get_scripts() {
return new WP_REST_Response( tah()->tvd_sm_get_scripts(), 200 );
}
/**
* Updates script order
*
* @param WP_REST_Request $request The request data from admin.
*
* @return WP_Error|WP_REST_Response
*/
public function order_scripts( $request ) {
/* flips the id with the index (which is used as the order afterwards) */
$new_script_order = array_flip( $request->get_param( 'scripts' ) );
$scripts = tah()->tvd_sm_get_scripts();
/* updates the order of scripts in this group : for every id that was changed, update the order */
foreach ( $scripts as $key => $script ) {
/* if the current iterated id exists in $new_script_order, then update the order */
if ( isset( $new_script_order[ $script['id'] ] ) ) {
$scripts[ $key ]['order'] = $new_script_order[ $script['id'] ];
}
}
if ( tah()->tvd_sm_update_option( 'global_lp_scripts', $scripts ) ) {
return new WP_REST_Response( $scripts, 200 );
} else {
return new WP_Error( 'cant-update-order', __( "Couldn't add/update the 'order' field in the database.", 'thrive-dash' ), array( 'status' => 500 ) );
}
}
/**
* Updates scripts
*
* @param WP_REST_Request $request The request data from admin.
*
* @return WP_Error|WP_REST_Response
*/
public function update_scripts( $request ) {
$script_id = $request->get_param( 'id' );
$array_to_add_edit = array(
'id' => $script_id,
'label' => $request->get_param( 'label' ),
'status' => $request->get_param( 'status' ),
'placement' => $request->get_param( 'placement' ),
'code' => $request->get_param( 'code' ),
'order' => $request->get_param( 'order' ),
'icon' => $request->get_param( 'icon' )
);
$scripts = tah()->tvd_sm_get_scripts();
if ( empty( $script_id ) ) {
/* add */
$script_id = tah()->tvd_sm_get_last_id_plus_one( $scripts );
$array_to_add_edit['id'] = $script_id;
$scripts[] = $array_to_add_edit;
} else {
/* edit */
$scripts[ tah()->tvd_sm_retrieve_key_for_id( $script_id, $scripts ) ] = $array_to_add_edit;
}
if ( tah()->tvd_sm_update_option( 'global_lp_scripts', $scripts ) ) {
return new WP_REST_Response( $array_to_add_edit, 200 );
} else {
return new WP_Error( 'cant-update', __( "Couldn't add/update the fields in the database.", 'thrive-dash' ), array( 'status' => 500 ) );
}
}
/**
* Deletes scripts
*
* @param WP_REST_Request $request The request data from admin.
*
* @return WP_Error|WP_REST_Response
*/
public function delete_script( $request ) {
$script_id = $request->get_param( 'id' );
$scripts = tah()->tvd_sm_get_scripts();
unset( $scripts[ tah()->tvd_sm_retrieve_key_for_id( $script_id, $scripts ) ] );
if ( update_option( 'global_lp_scripts', $scripts ) ) {
return new WP_REST_Response( $script_id, 200 );
} else {
return new WP_Error( 'cant-delete', __( "Couldn't delete the field from the database.", 'thrive-dash' ), array( 'status' => 500 ) );
}
}
/**
* If the user has access to the admin pages, then he is allowed to perform any operation on the scripts.
* @return bool
*/
public function general_permissions_check() {
return current_user_can( TVE_DASH_CAPABILITY );
}
}

View File

@@ -0,0 +1,16 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
include( TVD_SM_Constants::path( 'includes/admin/views/templates' ) . '/header.phtml' ); ?>
<div id="tvd-sm-breadcrumbs-wrapper"></div>
<div id="tvd-sm-wrapper">
<div id="tvd-sm-container">
</div>
</div>

View File

@@ -0,0 +1,5 @@
<div class="tvd-sm-breadcrumbs">
<a href="<?php echo admin_url( 'admin.php?page=tve_dash_section' ); ?>">
<?php echo __( 'Thrive Dashboard', 'thrive-dash' ); ?>
</a> &nbsp > &nbsp <strong><?php echo __( 'Analytics & Scripts', 'thrive-dash' ); ?></strong>
</div>

View File

@@ -0,0 +1,36 @@
<div class="tvd-section-title">
<h3><?php echo __( 'Analytics & Scripts', 'thrive-dash' ) ?>
<a class="tvd-add-modal tvd-waves-effect tvd-waves-light tvd-btn tvd-btn-blue"><?php echo __( 'ADD NEW', 'thrive-dash' ) ?></a>
</h3>
</div>
<div id="tve-dash-scripts">
<h4 class="tvd-sm-row">
<span class="tvd-sm-row-elem-placement"><?php echo __( 'Before ', 'thrive-dash' ) ?><?php echo htmlentities( '</head>' ); ?> </span>
<span class="tvd-sm-enabled tvd-sm-theme-column" style="<#= !TVD_SM_CONST.is_ttb_active ? 'display:none' : '' #>"><?php echo __( 'Inserted in Thrive Themes', 'thrive-dash' ) ?></span>
<span class="tvd-sm-enabled tvd-sm-lp-column" style="<#= !TVD_SM_CONST.is_tar_active ? 'display:none' : '' #>"><?php echo __( 'Inserted in Landing Pages', 'thrive-dash' ) ?></span>
<span class="tvd-sm-empty"></span>
</h4>
<div id="tvd-sm-container-head" class="tvd-sm-script-group">
</div>
<h4 class="tvd-sm-row">
<span class="tvd-sm-row-elem tvd-sm-row-elem-placement"><?php echo __( 'After ', 'thrive-dash' ) ?><?php echo htmlentities( '<body>' ); ?> </span>
</h4>
<div id="tvd-sm-container-body-open" class="tvd-sm-script-group">
</div>
<h4 class="tvd-sm-row">
<span class="tvd-sm-row-elem tvd-sm-row-elem-placement"><?php echo __( 'Before ', 'thrive-dash' ) ?><?php echo htmlentities( '</body>' ); ?> </span>
</h4>
<div id="tvd-sm-container-body-close" class="tvd-sm-script-group">
</div>
</div>
<div id="tvd-back-td" class="tvd-col tvd-m6">
<a href="<?php echo admin_url( 'admin.php?page=tve_dash_section' ); ?>" class="tvd-waves-effect tvd-waves-light tvd-btn-small tvd-btn-gray">
<?php echo __( 'Back To Dashboard', 'thrive-dash' ); ?>
</a>
</div>

View File

@@ -0,0 +1,33 @@
<?php /* taken from templates/header.phtml */ ?>
<div class="tvd-header">
<nav id="tvd-nav">
<div class="nav-wrapper">
<div class="tve-logo tvd-left">
<a href="<?php menu_page_url( 'tve_dash_section' ); ?>"
class="tvd-users-dashboard-logo"
title="<?php echo __( 'Thrive Dashboard', 'thrive-dash' ) ?>">
<span class="tvd-logo-container">
<img class="thrive_admin_logo"
src="<?php echo TVE_DASH_URL ?>/css/images/thrive-logo.png"
alt="">
</span>
</a>
</div>
<ul id="tvd-dash-submenu" class="tvd-right">
<li>
<a id="tvd-delete-page-level-scripts" href="javascript:void(0)">
<i class="tvd-icon-trash-o"></i>
<?php echo __( 'Delete All Page-Level Scripts', 'thrive-dash' ) ?></a>
</li>
<li>
<a id="tvd-share-modal" class="tvd-modal-trigger" href="#tvd-modal1"
data-overlay_class="tvd-white-bg" data-opacity=".95">
<span class="tvd-icon-heart"></span>
</a>
</li>
</ul>
</div>
</nav>
</div>
<?php include TVE_DASH_PATH . '/templates/share.phtml'; ?>

View File

@@ -0,0 +1,70 @@
<div class="tvd-modal-content tvd-modal-add-edit-script">
<h4 class="tvd-modal-title"><#= message #></h4>
<a href="javascript:void(0)"
class="tvd-modal-action tvd-modal-close tvd-modal-close-x">
<i class="tvd-icon-close2"></i>
</a>
<form class="">
<div class="tvd-row">
<div class="tvd-sm-form-element clearfix">
<label for="tvd-sm-script-code">
<?php echo __( 'Script', 'thrive-dash' ) ?>
</label>
<textarea id="tvd-sm-script-code"><#= typeof(this.model) !== 'undefined' ? this.model.get('code'):''#></textarea>
</div>
<div id="tvd-sm-code-empty" class="tvd-sm-input-error" hidden>
<?php echo __( 'Required field!', 'thrive-dash' ); ?>
</div>
<div id="tvd-sm-code-invalid" class="tvd-sm-input-error" hidden>
<?php echo __( 'Invalid code!', 'thrive-dash' ); ?>
</div>
<div class="tvd-sm-form-element">
<label class="tvd-sm-script-name" for="tvd-sm-script-name"><?php echo __( 'Script Label', 'thrive-dash' ) ?></label>
<input id="tvd-sm-script-name" type="text" value="<#= typeof(this.model) !== 'undefined' ? this.model.get('label') : '' #>">
</div>
<div id="tvd-sm-label-empty" class="tvd-sm-input-error no-space-top" hidden>
<?php echo __( 'Required field!', 'thrive-dash' ); ?>
</div>
<div class="tvd-sm-form-element">
<label class="tvd-sm-script-placement" for="tvd-sm-script-placement"><?php echo __( 'Placement', 'thrive-dash' ) ?></label>
<select id="tvd-sm-script-placement">
<option value="" disabled selected hidden><?php echo __( 'Choose placement', 'thrive-dash' ) ?></option>
<# _.each(TVD_SM_CONST.script_placement_text, function(value,key){ #>
<option value="<#= key #>"
<#= (typeof(this.model) !== 'undefined') && (key === this.model.get('placement')) ? "selected" : "" #>
>
<#= value #>
</option>
<# }, this); #>
</select>
</div>
<div id="tvd-sm-placement-empty" class="tvd-sm-input-error no-space-top" hidden>
<?php echo __( 'Required field!', 'thrive-dash' ); ?>
</div>
<div class="tvd-sm-form-element tvd-sm-location" style="<#= TVD_SM_CONST.is_ttb_active && TVD_SM_CONST.is_tar_active ? '' : 'display:none' #>">
<label class="tvd-sm-script-location"><?php echo __( 'Inserted in', 'thrive-dash' ) ?></label>
<input id="tvd-sm-script-checkbox-ttb" type="checkbox" <#= typeof(this.model) !== 'undefined' ? (this.model.get('status').ttb ? 'checked' : '') : '' #>>
<label for="tvd-sm-script-checkbox-ttb" class="tvd-sm-checkbox"> <?php echo __( 'Thrive Themes', 'thrive-dash' ); ?> </label>
<input id="tvd-sm-script-checkbox-lp" type="checkbox" <#= typeof(this.model) !== 'undefined' ? (this.model.get('status').lp ? 'checked' : '') : '' #>>
<label for="tvd-sm-script-checkbox-lp" class="tvd-sm-checkbox"> <?php echo __( 'Landing Pages', 'thrive-dash' ); ?> </label>
</div>
<div style="display:none">
<input id="tvd-sm-script-icon" type="text" value="<#= typeof(this.model) !== 'undefined' ? this.model.get('icon') : '' #>">
</div>
</div>
<div class="tvd-row tvd-row_wmb">
<a href="javascript:void(0)" class="tvd-modal-close tvd-btn-flat tvd-btn-flat-secondary tvd-btn-flat-dark tvd-waves-effect"><?php echo __( 'BACK', 'thrive-dash' ) ?></a>
<a href="javascript:void(0)" class="tvd-submit tvd-waves-effect tvd-waves-light tvd-btn tvd-right tvd-btn-green"><?php echo __( 'CONTINUE', 'thrive-dash' ) ?></a>
</div>
</form>
</div>

View File

@@ -0,0 +1,18 @@
<div class="tvd-col tvd-s6 tvd-ms6 tvd-m4 tvd-l3">
<div class="tvd-card tvd-small tvd-red tvd-sm-delete-custom">
<div class="tvd-card-content tvd-center-align">
<h4 class="tvd-margin-top">
<?php echo __( 'You are about to delete all the scripts you\'ve inserted on individual pages using the Thrive Architect editor. Do you want to proceed?', 'thrive-dash' ) ?>
</h4>
</div>
<div class="tvd-card-action">
<a class="tvd-modal-close tvd-btn-flat tvd-btn-flat-secondary tvd-btn-flat-light tvd-left tvd-waves-effect">
<?php echo __( 'No', 'thrive-dash' ) ?>
</a>
<a class="tvd-submit tvd-btn-flat tvd-btn-flat-primary tvd-btn-flat-light tvd-right tvd-waves-effect">
<?php echo __( 'Yes', 'thrive-dash' ) ?>
</a>
</div>
</div>
</div>
<a href="javascript:void(0)" class="tvd-modal-action tvd-modal-close tvd-modal-close-x tvd-white-text"><i class="tvd-icon-close2"></i></a>

View File

@@ -0,0 +1,18 @@
<div class="tvd-col tvd-s6 tvd-ms6 tvd-m4 tvd-l3">
<div class="tvd-card tvd-small tvd-red">
<div class="tvd-card-content tvd-center-align">
<h4 class="tvd-margin-top">
<?php echo __( 'Are you sure you want to delete this script?', 'thrive-dash' ) ?>
</h4>
</div>
<div class="tvd-card-action">
<a class="tvd-modal-close tvd-btn-flat tvd-btn-flat-secondary tvd-btn-flat-light tvd-left tvd-waves-effect">
<?php echo __( 'NO, DON\'T DELETE', 'thrive-dash' ) ?>
</a>
<a class="tvd-submit tvd-btn-flat tvd-btn-flat-primary tvd-btn-flat-light tvd-right tvd-waves-effect">
<?php echo __( 'YES, DELETE', 'thrive-dash' ) ?>
</a>
</div>
</div>
</div>
<a href="javascript:void(0)" class="tvd-modal-action tvd-modal-close tvd-modal-close-x tvd-white-text"><i class="tvd-icon-close2"></i></a>

View File

@@ -0,0 +1,26 @@
<span class="tvd-sm-script-elem tvd-sm-script-label">
<i class="tvd-icon-handle"></i>
<span class="<#= this.formIconClass() #>"></span>
<strong><#= this.model.get('label') #></strong>
</span>
<div class="tvd-sm-script-elem-switch tvd-switch" style="<#= !TVD_SM_CONST.is_ttb_active ? 'display:none' : '' #>">
<label>
<input type="checkbox" data-type="checkbox" data-location="ttb"
<#= this.model.get('status').ttb ? "checked" : "" #> >
<span class="tvd-lever"></span>
</label>
</div>
<div class="tvd-sm-script-elem-switch tvd-switch" style="<#= !TVD_SM_CONST.is_tar_active ? 'display:none' : '' #>">
<label>
<input type="checkbox" data-type="checkbox" data-location="lp"
<#= this.model.get('status').lp ? "checked" : "" #> >
<span class="tvd-lever"></span>
</label>
</div>
<span class="tvd-sm-script-elem-operations tvd-right-align">
<i class="tvd-edit-modal tvd-icon-pencil"></i>
<i class="tvd-delete-modal tvd-icon-trash-o"></i>
</span>

View File

@@ -0,0 +1,108 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden.
}
/**
* Class TVD_SM_Frontend
*/
class TVD_SM_Frontend {
const LP_HOOK_HEAD = 'tcb_landing_head_frontend';
const LP_HOOK_BODY_OPEN = 'tcb_landing_body_open_frontend';
const LP_HOOK_BODY_CLOSE = 'tcb_landing_body_close_frontend';
const THEME_LOCATION = 'ttb';
const LP_LOCATION = 'lp';
private $frontend_scripts = array(
TVD_SM_Constants::HEAD_PLACEMENT => array( self::THEME_LOCATION => '', self::LP_LOCATION => '' ),
TVD_SM_Constants::BODY_OPEN_PLACEMENT => array( self::THEME_LOCATION => '', self::LP_LOCATION => '' ),
TVD_SM_Constants::BODY_CLOSE_PLACEMENT => array( self::THEME_LOCATION => '', self::LP_LOCATION => '' ),
);
public function __construct() {
add_action( 'init', array( $this, 'init' ) );
}
/**
* The single instance of the class.
*
* @var TVD_SM_Frontend singleton instance.
*/
protected static $_instance = null;
/**
* Main TVD_SM_Frontend Instance.
* Ensures only one instance of TVD_SM_Frontend is loaded or can be loaded.
*
* @return TVD_SM_Frontend
*/
public static function instance() {
if ( static::$_instance === null ) {
static::$_instance = new self();
}
return static::$_instance;
}
public function init() {
/* update the script code */
$this->update_script_code();
/* hooks for adding scripts to specific sections of the landing pages or regular posts or pages */
add_action( static::LP_HOOK_HEAD, array( $this, 'head_scripts' ) );
add_action( static::LP_HOOK_BODY_OPEN, array( $this, 'body_open_scripts' ) );
add_action( static::LP_HOOK_BODY_CLOSE, array( $this, 'body_close_scripts' ) );
}
public function update_script_code() {
/* get all the scripts */
$scripts = tah()->tvd_sm_get_scripts();
/* sort the array according to the 'order' field */
usort( $scripts, array( tah(), 'sort_by_order' ) );
/* update the section strings */
foreach ( $scripts as $script ) {
foreach ( $script['status'] as $location => $status ) {
if ( isset( $script['placement'] ) && $status ) {
$this->frontend_scripts[ $script['placement'] ][ $location ] .= $script['code'];
}
}
}
}
public function theme_scripts( $placement ) {
return $this->frontend_scripts[ $placement ][ static::THEME_LOCATION ];
}
public function head_scripts() {
/* add all the head scripts */
echo $this->frontend_scripts[ TVD_SM_Constants::HEAD_PLACEMENT ][ static::LP_LOCATION ]; // phpcs:ignore
}
public function body_open_scripts() {
/* add all the body start scripts */
echo $this->frontend_scripts[ TVD_SM_Constants::BODY_OPEN_PLACEMENT ][ static::LP_LOCATION ]; // phpcs:ignore
}
public function body_close_scripts() {
/* add all the body end scripts */
echo $this->frontend_scripts[ TVD_SM_Constants::BODY_CLOSE_PLACEMENT ][ static::LP_LOCATION ]; // phpcs:ignore
}
}
/**
* @return TVD_SM_Frontend
*/
function TVD_SM_Frontend() {
return TVD_SM_Frontend::instance();
}
TVD_SM_Frontend();

View File

@@ -0,0 +1,23 @@
<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-dashboard
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden
}
return array(
'Thrive_Dashboard' => __( 'Thrive Dashboard', 'thrive-dash' ),
'SM_Dashboard' => __( 'Script Manager', 'thrive-dash' ),
'add_script' => __( 'Add New Script', 'thrive-dash' ),
'edit_script' => __( 'Edit Script', 'thrive-dash' ),
'add_error' => __( 'Error while adding a script!', 'thrive-dash' ),
'edit_success' => __( 'Script edited successfully.', 'thrive-dash' ),
'edit_error' => __( 'Error while editing a script!', 'thrive-dash' ),
'delete_error' => __( 'Error while deleting a script!', 'thrive-dash' ),
'delete_page_level_success' => __( 'Page-level scripts were deleted successfully.', 'thrive-dash' ),
'delete_page_level_error' => __( 'Error while deleting page-level scripts!', 'thrive-dash' ),
'no_scripts_in_this_group' => __( 'No scripts added in this area', 'thrive-dash' ),
);