Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/nexter-extension/content-fields/build/index.asset.php
+++ b/nexter-extension/content-fields/build/index.asset.php
@@ -5,5 +5,5 @@
'react-jsx-runtime',
'wp-i18n'
),
- 'version' => '7eaa5093c9893126bd9f'
+ 'version' => '75b08f3614be6e30ddd3'
);
--- a/nexter-extension/dashboard/build/index.asset.php
+++ b/nexter-extension/dashboard/build/index.asset.php
@@ -7,5 +7,5 @@
'wp-dom-ready',
'wp-i18n'
),
- 'version' => '3bb34f5285fe34d07778'
+ 'version' => '72ffcd674252ebc34743'
);
--- a/nexter-extension/include/classes/load-code-snippet/handlers/nexter-page-specific-code-handler.php
+++ b/nexter-extension/include/classes/load-code-snippet/handlers/nexter-page-specific-code-handler.php
@@ -2,7 +2,7 @@
/**
* Page-Specific Code Handler
* Handles content-based code snippet execution for posts, pages, and archives
- *
+ *
* @since 1.0.0
* @package Nexter Extensions
*/
@@ -42,7 +42,7 @@
'after_x_executed' => array(),
'after_x_last_queue' => array(),
);
-
+
/**
* Get instance
*/
@@ -59,78 +59,79 @@
* Using WordPress core hooks for better compatibility with live sites
*/
public static function get_page_specific_location_hooks() {
- return [
+ return array(
// Page-Specific - Page, Post, Custom Post Type
'insert_before_post' => 'the_post', // Hook into the_post action for proper post element insertion
'insert_after_post' => 'the_content', // Hook into the_content filter for proper post element insertion
'insert_before_content' => 'the_content',
'insert_after_content' => 'the_content',
-
+
// Paragraph-level insertions (handled specially through content filter)
'insert_before_paragraph' => 'the_content',
'insert_after_paragraph' => 'the_content',
-
+
// Archive-specific locations - use template_redirect for better timing
'insert_before_excerpt' => 'template_redirect',
'insert_after_excerpt' => 'template_redirect',
'between_posts' => 'template_redirect',
'before_post' => 'template_redirect',
'after_post' => 'template_redirect',
- ];
+ );
}
/**
* Get advanced content insertion locations
*/
public static function get_advanced_content_locations() {
- return [
+ return array(
'insert_after_words',
- 'insert_every_words',
+ 'insert_every_words',
'insert_middle_content',
'insert_after_25',
- 'insert_after_33',
+ 'insert_after_33',
'insert_after_66',
'insert_after_75',
- 'insert_after_80'
- ];
+ 'insert_after_80',
+ );
}
/**
* Check if location is page-specific
*/
- public static function is_page_specific_location($location) {
+ public static function is_page_specific_location( $location ) {
$page_locations = array_keys( self::get_page_specific_location_hooks() );
$advanced_locations = self::get_advanced_content_locations();
- $archive_locations = self::is_archive_based_location( $location ) ? [$location] : [];
+ $archive_locations = self::is_archive_based_location( $location ) ? array( $location ) : array();
return in_array( $location, array_merge( $page_locations, $advanced_locations, $archive_locations ) );
}
/**
* Check if location is advanced content location
*/
- public static function is_advanced_content_location($location) {
+ public static function is_advanced_content_location( $location ) {
return in_array( $location, self::get_advanced_content_locations() );
}
/**
* Check if location is content-based (uses the_content filter)
*/
- public static function is_content_based_location($location) {
- $content_locations = [
+ public static function is_content_based_location( $location ) {
+ $content_locations = array(
'insert_before_content',
- 'insert_after_content',
+ 'insert_after_content',
'insert_before_paragraph',
- 'insert_after_paragraph'
- ];
+ 'insert_after_paragraph',
+ );
return in_array( $location, $content_locations );
}
/**
* Check if location is excerpt-based (uses get_the_excerpt filter) - DEPRECATED
* These are now handled as archive-based locations
+ *
* @deprecated No longer used - excerpt locations moved to archive-based
*/
- public static function is_excerpt_based_location($location) {
+ public static function is_excerpt_based_location( $location ) {
// All excerpt locations are now archive-based
return false;
}
@@ -139,34 +140,34 @@
* Check if location is post-based (uses the_post action) - FOR SINGULAR PAGES ONLY
* Archive post locations are now handled as archive-based
*/
- public static function is_post_based_location($location) {
- $post_locations = [
+ public static function is_post_based_location( $location ) {
+ $post_locations = array(
'insert_before_post', // Singular page "insert before post"
- 'insert_after_post' // Singular page "insert after post"
- ];
+ 'insert_after_post', // Singular page "insert after post"
+ );
return in_array( $location, $post_locations );
}
/**
* Check if location is archive-based (requires archive pages)
*/
- public static function is_archive_based_location($location) {
+ public static function is_archive_based_location( $location ) {
$archive_locations = array(
'insert_before_excerpt',
'insert_after_excerpt',
'between_posts',
'before_post',
'before_x_post',
- 'after_x_post'
+ 'after_x_post',
);
-
+
return in_array( $location, $archive_locations );
}
/**
* Handle content insertion based on location
*/
- private static function handle_content_insertion($content, $insert_content, $location, $snippet_id) {
+ private static function handle_content_insertion( $content, $insert_content, $location, $snippet_id ) {
if ( self::is_advanced_content_location( $location ) ) {
return self::insert_content_at_advanced_location( $content, $insert_content, $location, $snippet_id );
}
@@ -188,21 +189,21 @@
$insert_content = ob_get_clean();
}
}
-
+
switch ( $location ) {
case 'insert_before_content':
return $insert_content . $content;
-
+
case 'insert_after_content':
case 'insert_after_post':
return $content . $insert_content;
-
+
case 'insert_before_paragraph':
return self::insert_before_first_paragraph( $content, $insert_content );
-
+
case 'insert_after_paragraph':
return self::insert_after_first_paragraph( $content, $insert_content );
-
+
default:
return $content;
}
@@ -211,35 +212,35 @@
/**
* Get enqueue hook for page-specific locations
*/
- public static function get_page_specific_enqueue_hook($location) {
+ public static function get_page_specific_enqueue_hook( $location ) {
$frontend_header_locations = array(
'before_content',
- 'insert_before_content',
- 'insert_before_post',
+ 'insert_before_content',
+ 'insert_before_post',
'insert_before_excerpt',
- 'insert_before_paragraph',
- 'before_post',
+ 'insert_before_paragraph',
+ 'before_post',
// Advanced content insertion locations
'insert_after_words',
- 'insert_every_words',
- 'insert_middle_content',
+ 'insert_every_words',
+ 'insert_middle_content',
'insert_after_25',
- 'insert_after_33',
- 'insert_after_66',
- 'insert_after_75',
- 'insert_after_80'
+ 'insert_after_33',
+ 'insert_after_66',
+ 'insert_after_75',
+ 'insert_after_80',
);
$frontend_footer_locations = array(
'after_content',
- 'insert_after_content',
- 'insert_after_post',
+ 'insert_after_content',
+ 'insert_after_post',
'insert_after_excerpt',
- 'insert_after_paragraph',
- 'after_post'
+ 'insert_after_paragraph',
+ 'after_post',
);
-
+
// Archive-based locations (between_posts) should use wp_head for CSS/JS
- $archive_header_locations = array('between_posts');
+ $archive_header_locations = array( 'between_posts' );
if ( in_array( $location, $frontend_header_locations ) || in_array( $location, $archive_header_locations ) ) {
return 'wp_head';
@@ -253,12 +254,12 @@
/**
* Execute PHP code for page-specific locations
*/
- public static function execute_page_specific_php($snippet_id, $code, $location) {
+ public static function execute_page_specific_php( $snippet_id, $code, $location ) {
if ( ! self::is_page_specific_location( $location ) ) {
return false;
}
- $hook_priority = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-hooks-priority', true ) : (is_array( $code ) && isset( $code['hooks_priority'] ) ? $code['hooks_priority'] : 10);
+ $hook_priority = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-hooks-priority', true ) : ( is_array( $code ) && isset( $code['hooks_priority'] ) ? $code['hooks_priority'] : 10 );
$priority = ! empty( $hook_priority ) ? intval( $hook_priority ) : 10;
$item = array(
'snippet_id' => $snippet_id,
@@ -290,19 +291,19 @@
}
self::$php_runtime['registered'] = true;
- add_filter( 'the_content', array(__CLASS__, 'dispatch_php_content'), 10, 1 );
- add_filter( 'the_excerpt', array(__CLASS__, 'dispatch_php_excerpt'), 10, 1 );
- add_action( 'the_post', array(__CLASS__, 'dispatch_php_loop'), 10, 2 );
- add_action( 'loop_end', array(__CLASS__, 'dispatch_php_loop_end'), 10, 0 );
+ add_filter( 'the_content', array( __CLASS__, 'dispatch_php_content' ), 10, 1 );
+ add_filter( 'the_excerpt', array( __CLASS__, 'dispatch_php_excerpt' ), 10, 1 );
+ add_action( 'the_post', array( __CLASS__, 'dispatch_php_loop' ), 10, 2 );
+ add_action( 'loop_end', array( __CLASS__, 'dispatch_php_loop_end' ), 10, 0 );
}
- private static function is_php_runtime_item_executable($snippet_id, $code) {
- $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : (is_array( $code ) && isset( $code['status'] ) ? $code['status'] : 0);
+ private static function is_php_runtime_item_executable( $snippet_id, $code ) {
+ $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : ( is_array( $code ) && isset( $code['status'] ) ? $code['status'] : 0 );
if ( (string) $is_active !== '1' ) {
return false;
}
- $code_hidden_execute = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-php-hidden-execute', true ) : (is_array( $code ) && isset( $code['php_hidden_execute'] ) ? $code['php_hidden_execute'] : 'no');
+ $code_hidden_execute = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-php-hidden-execute', true ) : ( is_array( $code ) && isset( $code['php_hidden_execute'] ) ? $code['php_hidden_execute'] : 'no' );
if ( $code_hidden_execute !== 'yes' ) {
return false;
}
@@ -310,7 +311,7 @@
return ! self::should_skip_due_to_schedule_restrictions( $snippet_id );
}
- private static function execute_php_capture_output($snippet_id, $code) {
+ private static function execute_php_capture_output( $snippet_id, $code ) {
ob_start();
if ( class_exists( 'Nexter_Builder_Code_Snippets_Executor' ) ) {
Nexter_Builder_Code_Snippets_Executor::get_instance()->execute_php_snippet( $code, $snippet_id );
@@ -318,7 +319,7 @@
return ob_get_clean();
}
- public static function dispatch_php_content($content) {
+ public static function dispatch_php_content( $content ) {
if ( empty( self::$php_runtime['content'] ) ) {
return $content;
}
@@ -329,7 +330,7 @@
$items = self::$php_runtime['content'];
usort(
$items,
- function($a, $b) {
+ function ( $a, $b ) {
return intval( $a['priority'] ) <=> intval( $b['priority'] );
}
);
@@ -350,7 +351,7 @@
return $content;
}
- public static function dispatch_php_excerpt($excerpt) {
+ public static function dispatch_php_excerpt( $excerpt ) {
if ( empty( self::$php_runtime['excerpt'] ) ) {
return $excerpt;
}
@@ -361,7 +362,7 @@
$items = self::$php_runtime['excerpt'];
usort(
$items,
- function($a, $b) {
+ function ( $a, $b ) {
return intval( $a['priority'] ) <=> intval( $b['priority'] );
}
);
@@ -386,15 +387,15 @@
return $excerpt;
}
- public static function dispatch_php_loop($post_object, $query) {
- if ( empty( self::$php_runtime['loop'] ) || is_admin() || ( ! is_archive() && ! is_home() && ! is_singular()) ) {
+ public static function dispatch_php_loop( $post_object, $query ) {
+ if ( empty( self::$php_runtime['loop'] ) || is_admin() || ( ! is_archive() && ! is_home() && ! is_singular() ) ) {
return;
}
$items = self::$php_runtime['loop'];
usort(
$items,
- function($a, $b) {
+ function ( $a, $b ) {
return intval( $a['priority'] ) <=> intval( $b['priority'] );
}
);
@@ -422,7 +423,7 @@
}
$current_post_index = isset( $query->current_post ) ? intval( $query->current_post ) + 1 : 1;
- $target_post_number = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-post-number', true ) : (is_array( $code ) && isset( $code['post_number'] ) ? $code['post_number'] : 1);
+ $target_post_number = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-post-number', true ) : ( is_array( $code ) && isset( $code['post_number'] ) ? $code['post_number'] : 1 );
$target_post_number = max( 1, intval( $target_post_number ) );
if ( $location === 'before_post' ) {
@@ -448,15 +449,15 @@
if ( $location === 'after_x_post' ) {
$execution_key = $snippet_id . '_' . $target_post_number;
- if ( $current_post_index === ($target_post_number + 1) && empty( self::$php_runtime['after_x_executed'][ $execution_key ] ) ) {
+ if ( $current_post_index === ( $target_post_number + 1 ) && empty( self::$php_runtime['after_x_executed'][ $execution_key ] ) ) {
self::$php_runtime['after_x_executed'][ $execution_key ] = true;
if ( class_exists( 'Nexter_Builder_Code_Snippets_Executor' ) ) {
Nexter_Builder_Code_Snippets_Executor::get_instance()->execute_php_snippet( $code, $snippet_id );
}
- } elseif ( $current_post_index === $target_post_number && isset( $query->post_count ) && ($query->current_post + 1) >= $query->post_count ) {
+ } elseif ( $current_post_index === $target_post_number && isset( $query->post_count ) && ( $query->current_post + 1 ) >= $query->post_count ) {
self::$php_runtime['after_x_last_queue'][ $execution_key ] = array(
- 'snippet_id' => $snippet_id,
- 'code' => $code
+ 'snippet_id' => $snippet_id,
+ 'code' => $code,
);
}
}
@@ -600,9 +601,9 @@
}
usort(
$items,
- function( $a, $b ) {
+ function ( $a, $b ) {
return intval( $a['priority'] ) <=> intval( $b['priority'] );
- }
+ }
);
return $items;
}
@@ -748,7 +749,7 @@
/**
* Check if snippet should execute
*/
- private static function should_execute_snippet($snippet_id) {
+ private static function should_execute_snippet( $snippet_id ) {
$is_active = get_post_meta( $snippet_id, 'nxt-code-status', true );
if ( $is_active != '1' ) {
return false;
@@ -757,21 +758,21 @@
// Check author permissions (security)
$authorID = get_post_field( 'post_author', $snippet_id );
$theAuthorDataRoles = get_userdata( $authorID );
- $theRolesAuthor = isset( $theAuthorDataRoles->roles ) ? $theAuthorDataRoles->roles : [];
-
+ $theRolesAuthor = isset( $theAuthorDataRoles->roles ) ? $theAuthorDataRoles->roles : array();
+
if ( ! in_array( 'administrator', $theRolesAuthor ) ) {
return false;
}
// Check PHP execution permission
$code_hidden_execute = get_post_meta( $snippet_id, 'nxt-code-php-hidden-execute', true );
- return ($code_hidden_execute === 'yes');
+ return ( $code_hidden_execute === 'yes' );
}
/**
* Execute PHP safely
*/
- private static function execute_php_safely($snippet_id, $code) {
+ private static function execute_php_safely( $snippet_id, $code ) {
if ( class_exists( 'Nexter_Builder_Code_Snippets_Executor' ) ) {
$result = Nexter_Builder_Code_Snippets_Executor::get_instance()->execute_php_snippet( $code, $snippet_id, false );
if ( is_wp_error( $result ) ) {
@@ -790,7 +791,7 @@
/**
* Enqueue CSS for page-specific locations
*/
- public static function enqueue_page_specific_css($snippet_id, $css, $location) {
+ public static function enqueue_page_specific_css( $snippet_id, $css, $location ) {
if ( ! self::is_page_specific_location( $location ) ) {
return false;
}
@@ -799,23 +800,23 @@
return self::queue_page_specific_asset( 'css', $snippet_id, $css, $location );
// Get priority from post meta, default to appropriate values
- $hook_priority = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-hooks-priority', true ) : (is_array( $css ) && isset( $css['hooksPriority'] ) ? $css['hooksPriority'] : 10);
+ $hook_priority = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-hooks-priority', true ) : ( is_array( $css ) && isset( $css['hooksPriority'] ) ? $css['hooksPriority'] : 10 );
$priority = ! empty( $hook_priority ) ? intval( $hook_priority ) : 10;
$filter_priority = ! empty( $hook_priority ) ? intval( $hook_priority ) : 9; // For content filters
// For content-based locations, inject CSS directly into content
- if ( self::is_content_based_location( $location ) ||
+ if ( self::is_content_based_location( $location ) ||
self::is_advanced_content_location( $location ) ) {
-
+
add_filter(
'the_content',
- function($content) use ($css, $snippet_id, $location) {
+ function ( $content ) use ( $css, $snippet_id, $location ) {
// Only process on singular pages and in the main query
if ( ! is_singular() || ! in_the_loop() || ! is_main_query() ) {
return $content;
}
- $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : (is_array( $css ) && isset( $css['status'] ) ? $css['status'] : 0);
+ $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : ( is_array( $css ) && isset( $css['status'] ) ? $css['status'] : 0 );
if ( $is_active != '1' ) {
return $content;
}
@@ -833,7 +834,7 @@
// Wrap CSS in style tags for content injection
$css_wrapped = '<style id="nexter-snippet-' . esc_attr( $snippet_id ) . '">' . $css . '</style>';
-
+
return self::handle_content_insertion( $content, $css_wrapped, $location, $snippet_id );
},
$priority
@@ -843,18 +844,18 @@
// For archive-based locations, inject CSS based on location
if ( self::is_archive_based_location( $location ) ) {
-
+
// Handle excerpt-based CSS insertions on archive pages
- if ( in_array( $location, ['insert_before_excerpt', 'insert_after_excerpt'] ) ) {
+ if ( in_array( $location, array( 'insert_before_excerpt', 'insert_after_excerpt' ) ) ) {
add_filter(
'the_excerpt',
- function($excerpt) use ($css, $snippet_id, $location) {
+ function ( $excerpt ) use ( $css, $snippet_id, $location ) {
// Only on archive or home pages
if ( ! is_archive() && ! is_home() ) {
return $excerpt;
}
- $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : (is_array( $css ) && isset( $css['status'] ) ? $css['status'] : 0);
+ $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : ( is_array( $css ) && isset( $css['status'] ) ? $css['status'] : 0 );
if ( $is_active != '1' ) {
return $excerpt;
}
@@ -890,13 +891,13 @@
$hook = self::get_page_specific_enqueue_hook( $location );
add_action(
$hook,
- function() use ($css, $snippet_id, $location) {
+ function () use ( $css, $snippet_id, $location ) {
// For archive-based locations, only enqueue on archive/home pages
if ( self::is_archive_based_location( $location ) && ! is_archive() && ! is_home() ) {
return;
}
- $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : (is_array( $css ) && isset( $css['status'] ) ? $css['status'] : 0);
+ $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : ( is_array( $css ) && isset( $css['status'] ) ? $css['status'] : 0 );
if ( $is_active != '1' ) {
return;
}
@@ -922,8 +923,8 @@
$hook = self::get_page_specific_enqueue_hook( $location );
add_action(
$hook,
- function() use ($css, $snippet_id, $location) {
- $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : (is_array( $css ) && isset( $css['status'] ) ? $css['status'] : 0);
+ function () use ( $css, $snippet_id, $location ) {
+ $is_active = is_numeric( $snippet_id ) ? get_post_meta( $snippet_id, 'nxt-code-status', true ) : ( is_array( $css ) && isset( $css['status'] ) ? $css['status'] : 0 );
if ( $is_active != '1' ) {
return;
}
@@ -946,11 +947,11 @@
return true;
}
-
+
/**
* Enqueue JavaScript for page-specific locations
*/
- public static function enqueue_page_specific_js($snippet_id, $js, $location) {
+ public static function enqueue_page_specific_js( $snippet_id, $js, $location ) {
if ( ! self::is_page_specific_location( $location ) ) {
return false;
}
@@ -962,20 +963,20 @@
$is_numeric_id = is_numeric( $snippet_id );
$priority = $is_numeric_id
- ? (intval( get_post_meta( $snippet_id, 'nxt-code-hooks-priority', true ) ) ?: 10)
- : (intval( is_array( $js ) && isset( $js['hooksPriority'] ) ? $js['hooksPriority'] : 10 ) ?: 10);
+ ? ( intval( get_post_meta( $snippet_id, 'nxt-code-hooks-priority', true ) ) ?: 10 )
+ : ( intval( is_array( $js ) && isset( $js['hooksPriority'] ) ? $js['hooksPriority'] : 10 ) ?: 10 );
/**
* Helper: check if snippet is active
*/
- $is_active_snippet = function() use ($snippet_id, $js, $is_numeric_id) {
+ $is_active_snippet = function () use ( $snippet_id, $js, $is_numeric_id ) {
if ( $is_numeric_id ) {
$status = get_post_meta( $snippet_id, 'nxt-code-status', true );
} else {
- $status = (is_array( $js ) && isset( $js['status'] )) ? $js['status'] : 0;
+ $status = ( is_array( $js ) && isset( $js['status'] ) ) ? $js['status'] : 0;
}
- return ($status === '1' || $status === 1);
+ return ( $status === '1' || $status === 1 );
};
/**
@@ -984,7 +985,7 @@
*/
$prepared_js = null;
- $prepare_js = function() use (&$prepared_js, $snippet_id, $js, $is_numeric_id) {
+ $prepare_js = function () use ( &$prepared_js, $snippet_id, $js, $is_numeric_id ) {
if ( $prepared_js !== null ) {
return $prepared_js;
}
@@ -1024,7 +1025,7 @@
/**
* Helper: get <script> tag wrapper (uses prepared JS).
*/
- $get_script_tag = function() use ($prepare_js, $snippet_id) {
+ $get_script_tag = function () use ( $prepare_js, $snippet_id ) {
$code = $prepare_js();
if ( $code === '' || $code === null ) {
@@ -1043,7 +1044,7 @@
add_filter(
'the_content',
- function($content) use ($snippet_id, $location, $is_active_snippet, $get_script_tag) {
+ function ( $content ) use ( $snippet_id, $location, $is_active_snippet, $get_script_tag ) {
// Only process on singular pages and in the main query
if ( ! is_singular() || ! in_the_loop() || ! is_main_query() ) {
return $content;
@@ -1074,11 +1075,11 @@
if ( self::is_archive_based_location( $location ) ) {
// Excerpt-based JS insertion
- if ( in_array( $location, array('insert_before_excerpt', 'insert_after_excerpt'), true ) ) {
+ if ( in_array( $location, array( 'insert_before_excerpt', 'insert_after_excerpt' ), true ) ) {
add_filter(
'the_excerpt',
- function($excerpt) use ($location, $is_active_snippet, $get_script_tag) {
+ function ( $excerpt ) use ( $location, $is_active_snippet, $get_script_tag ) {
// Only on archive or home pages
if ( ! is_archive() && ! is_home() ) {
return $excerpt;
@@ -1108,16 +1109,16 @@
}
// Loop-based archive locations
- if ( in_array( $location, array('between_posts', 'before_post', 'before_x_post', 'after_x_post'), true ) ) {
+ if ( in_array( $location, array( 'between_posts', 'before_post', 'before_x_post', 'after_x_post' ), true ) ) {
// before_post -> before every post in loop
if ( $location === 'before_post' ) {
add_action(
'the_post',
- function($post_object, $query) use ($is_active_snippet, $get_script_tag) {
+ function ( $post_object, $query ) use ( $is_active_snippet, $get_script_tag ) {
// Only on frontend archive or home pages
- if ( is_admin() || ( ! is_archive() && ! is_home()) ) {
+ if ( is_admin() || ( ! is_archive() && ! is_home() ) ) {
return;
}
@@ -1142,8 +1143,8 @@
add_action(
'the_post',
- function($post_object, $query) use ($snippet_id, $js, $is_numeric_id, $is_active_snippet, $get_script_tag) {
- if ( is_admin() || ( ! is_archive() && ! is_home()) ) {
+ function ( $post_object, $query ) use ( $snippet_id, $js, $is_numeric_id, $is_active_snippet, $get_script_tag ) {
+ if ( is_admin() || ( ! is_archive() && ! is_home() ) ) {
return;
}
@@ -1154,7 +1155,7 @@
// Target post number (1-indexed)
$target_post_number = $is_numeric_id
? get_post_meta( $snippet_id, 'nxt-post-number', true )
- : (is_array( $js ) && isset( $js['post_number'] ) ? $js['post_number'] : 1);
+ : ( is_array( $js ) && isset( $js['post_number'] ) ? $js['post_number'] : 1 );
$target_post_number = intval( $target_post_number ) ?: 1;
@@ -1181,9 +1182,9 @@
add_action(
'the_post',
- function($post_object, $query) use ($snippet_id, $js, $is_numeric_id, $is_active_snippet, $get_script_tag, &$executed_after_x_post_js) {
+ function ( $post_object, $query ) use ( $snippet_id, $js, $is_numeric_id, $is_active_snippet, $get_script_tag, &$executed_after_x_post_js ) {
- if ( is_admin() || ( ! is_archive() && ! is_home()) ) {
+ if ( is_admin() || ( ! is_archive() && ! is_home() ) ) {
return;
}
@@ -1194,7 +1195,7 @@
// Target post number (1-indexed)
$target_post_number = $is_numeric_id
? get_post_meta( $snippet_id, 'nxt-post-number', true )
- : (is_array( $js ) && isset( $js['post_number'] ) ? $js['post_number'] : 1);
+ : ( is_array( $js ) && isset( $js['post_number'] ) ? $js['post_number'] : 1 );
$target_post_number = intval( $target_post_number ) ?: 1;
@@ -1216,7 +1217,7 @@
}
}
// Edge case: target is last post
- elseif ( $current_post_index === $target_post_number && ($query->current_post + 1) >= $query->post_count ) {
+ elseif ( $current_post_index === $target_post_number && ( $query->current_post + 1 ) >= $query->post_count ) {
$execution_key = $snippet_id . '_' . $target_post_number . '_last';
if ( ! isset( $executed_after_x_post_js[ $execution_key ] ) ) {
@@ -1229,7 +1230,7 @@
add_action(
'loop_end',
- function() use ($js_wrapped, $snippet_id) {
+ function () use ( $js_wrapped, $snippet_id ) {
echo $js_wrapped; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
},
10
@@ -1247,8 +1248,8 @@
add_action(
'the_post',
- function($post_object, $query) use ($is_active_snippet, $get_script_tag) {
- if ( is_admin() || ( ! is_archive() && ! is_home()) ) {
+ function ( $post_object, $query ) use ( $is_active_snippet, $get_script_tag ) {
+ if ( is_admin() || ( ! is_archive() && ! is_home() ) ) {
return;
}
@@ -1284,7 +1285,7 @@
add_action(
$hook,
- function() use ($location, $is_active_snippet, $get_script_tag) {
+ function () use ( $location, $is_active_snippet, $get_script_tag ) {
if ( self::is_archive_based_location( $location ) && ! is_archive() && ! is_home() ) {
return;
}
@@ -1317,7 +1318,7 @@
add_action(
$hook,
- function() use ($is_active_snippet, $get_script_tag) {
+ function () use ( $is_active_snippet, $get_script_tag ) {
if ( ! $is_active_snippet() ) {
return;
}
@@ -1339,9 +1340,9 @@
/**
* Output HTML for page-specific locations
*
- * @param int|mixed $snippet_id
- * @param mixed $html
- * @param string $location
+ * @param int|mixed $snippet_id
+ * @param mixed $html
+ * @param string $location
*
* @return bool
*/
@@ -1691,22 +1692,22 @@
/**
* Check if HTML snippet should execute
*/
- private static function should_execute_html_snippet($snippet_id) {
+ private static function should_execute_html_snippet( $snippet_id ) {
$is_active = get_post_meta( $snippet_id, 'nxt-code-status', true );
- return ($is_active == '1');
+ return ( $is_active == '1' );
}
/**
* Register loop-specific hooks
*/
- private static function register_loop_hooks($snippet_id, $html, $location, $priority) {
+ private static function register_loop_hooks( $snippet_id, $html, $location, $priority ) {
static $post_counter = 0;
-
+
switch ( $location ) {
case 'between_posts':
add_action(
'the_post',
- function() use ($snippet_id, $html, &$post_counter) {
+ function () use ( $snippet_id, $html, &$post_counter ) {
if ( $post_counter > 0 ) { // Not the first post
$is_active = get_post_meta( $snippet_id, 'nxt-code-status', true );
if ( $is_active == '1' ) {
@@ -1718,11 +1719,11 @@
$priority
);
break;
-
+
case 'before_post':
add_action(
'the_post',
- function() use ($snippet_id, $html) {
+ function () use ( $snippet_id, $html ) {
$is_active = get_post_meta( $snippet_id, 'nxt-code-status', true );
if ( $is_active == '1' ) {
echo apply_filters( 'nexter_html_snippets_executed', $html, $snippet_id );
@@ -1731,11 +1732,11 @@
$priority - 1
); // Before the_post
break;
-
+
case 'after_post':
add_action(
'the_post',
- function() use ($snippet_id, $html) {
+ function () use ( $snippet_id, $html ) {
$is_active = get_post_meta( $snippet_id, 'nxt-code-status', true );
if ( $is_active == '1' ) {
echo apply_filters( 'nexter_html_snippets_executed', $html, $snippet_id );
@@ -1750,7 +1751,7 @@
/**
* Insert content at advanced locations (word/percentage based)
*/
- private static function insert_content_at_advanced_location($content, $insert_content, $location, $snippet_id) {
+ private static function insert_content_at_advanced_location( $content, $insert_content, $location, $snippet_id ) {
// All advanced content locations are Pro features
// Route them through the Pro plugin filter system
return apply_filters( 'nexter_process_pro_content_insertion', $content, $location, $insert_content, $snippet_id );
@@ -1759,32 +1760,32 @@
/**
* Insert content after a specific word count
*/
- private static function insert_after_word_count($content, $insert_content, $target_words) {
+ private static function insert_after_word_count( $content, $insert_content, $target_words ) {
// Split content into words while preserving HTML structure
$words = preg_split( '/(s+)/', $content, -1, PREG_SPLIT_DELIM_CAPTURE );
$current_word_count = 0;
$insert_position = 0;
-
+
foreach ( $words as $index => $word ) {
if ( trim( $word ) !== '' && ! preg_match( '/<[^>]*>/', $word ) ) {
// This is an actual word (not whitespace or HTML tag)
$word_count_in_segment = str_word_count( strip_tags( $word ) );
$current_word_count += $word_count_in_segment;
-
+
if ( $current_word_count >= $target_words ) {
$insert_position = $index;
break;
}
}
}
-
+
if ( $insert_position > 0 ) {
// Insert content at the calculated position
$before = implode( '', array_slice( $words, 0, $insert_position ) );
$after = implode( '', array_slice( $words, $insert_position ) );
return $before . $insert_content . $after;
}
-
+
// If target word count not reached, append at the end
return $content . $insert_content;
}
@@ -1792,42 +1793,42 @@
/**
* Insert content at regular word intervals throughout the content
*/
- private static function insert_every_word_count($content, $insert_content, $word_interval) {
+ private static function insert_every_word_count( $content, $insert_content, $word_interval ) {
// Split content into words while preserving HTML structure
$words = preg_split( '/(s+)/', $content, -1, PREG_SPLIT_DELIM_CAPTURE );
$current_word_count = 0;
$insertions_made = 0;
- $result_words = [];
-
+ $result_words = array();
+
foreach ( $words as $index => $word ) {
$result_words[] = $word;
-
+
if ( trim( $word ) !== '' && ! preg_match( '/<[^>]*>/', $word ) ) {
// This is an actual word (not whitespace or HTML tag)
$word_count_in_segment = str_word_count( strip_tags( $word ) );
$current_word_count += $word_count_in_segment;
-
+
// Check if we've reached the interval
- if ( $current_word_count >= $word_interval * ($insertions_made + 1) ) {
+ if ( $current_word_count >= $word_interval * ( $insertions_made + 1 ) ) {
$result_words[] = $insert_content;
- $insertions_made++;
+ ++$insertions_made;
}
}
}
-
+
return implode( '', $result_words );
}
/**
* Insert content before first paragraph
*/
- private static function insert_before_first_paragraph($content, $insert_content) {
+ private static function insert_before_first_paragraph( $content, $insert_content ) {
// Look for the first <p> tag
if ( preg_match( '/<pb[^>]*>/i', $content, $matches, PREG_OFFSET_CAPTURE ) ) {
$insert_position = $matches[0][1];
return substr( $content, 0, $insert_position ) . $insert_content . substr( $content, $insert_position );
}
-
+
// If no paragraph found, prepend to content
return $insert_content . $content;
}
@@ -1835,13 +1836,13 @@
/**
* Insert content after first paragraph
*/
- private static function insert_after_first_paragraph($content, $insert_content) {
+ private static function insert_after_first_paragraph( $content, $insert_content ) {
// Look for the first complete <p>...</p> block
if ( preg_match( '/<pb[^>]*>.*?</p>/si', $content, $matches, PREG_OFFSET_CAPTURE ) ) {
$insert_position = $matches[0][1] + strlen( $matches[0][0] );
return substr( $content, 0, $insert_position ) . $insert_content . substr( $content, $insert_position );
}
-
+
// If no paragraph found, append to content
return $content . $insert_content;
}
@@ -1849,18 +1850,18 @@
/**
* Compress CSS by removing comments and extra whitespace
*/
- private static function compress_css($css) {
+ private static function compress_css( $css ) {
// Remove comments
$css = preg_replace( '!/*[^*]**+([^/][^*]**+)*/!', '', $css );
// Remove unnecessary whitespace
- $css = str_replace( array("rn", "r", "n", "t", ' ', ' ', ' '), '', $css );
+ $css = str_replace( array( "rn", "r", "n", "t", ' ', ' ', ' ' ), '', $css );
return trim( $css );
}
/**
* Compress JavaScript by removing comments and extra whitespace
*/
- private static function compress_js($js) {
+ private static function compress_js( $js ) {
// Remove single-line comments (but preserve URLs)
$js = preg_replace( '/(?<![:'])//.*$/m', '', $js );
// Remove multi-line comments
@@ -1874,14 +1875,14 @@
* Check if snippet should be skipped due to schedule restrictions
* Uses the same logic as the main system
*/
- private static function should_skip_due_to_schedule_restrictions($snippet_id) {
+ private static function should_skip_due_to_schedule_restrictions( $snippet_id ) {
// Check if Pro plugin is available for schedule restrictions
if ( defined( 'NXT_PRO_EXT' ) && function_exists( 'apply_filters' ) ) {
$should_skip = apply_filters( 'nexter_check_pro_schedule_restrictions', false, $snippet_id );
return $should_skip;
}
-
+
// If no Pro plugin, no schedule restrictions to check
return false;
}
-}
No newline at end of file
+}
--- a/nexter-extension/include/classes/load-code-snippet/nexter-code-snippet-render.php
+++ b/nexter-extension/include/classes/load-code-snippet/nexter-code-snippet-render.php
@@ -33,10 +33,10 @@
public static $snippet_ids = array();
public static $snippet_loaded_ids = array(
- 'css' => [],
- 'javascript' => [],
- 'php' => [],
- 'htmlmixed' => [],
+ 'css' => array(),
+ 'javascript' => array(),
+ 'php' => array(),
+ 'htmlmixed' => array(),
);
public static $snippet_output = array();
@@ -74,7 +74,7 @@
*
* @var array<int, array<string, array>>
*/
- private static $post_meta_cache = [];
+ private static $post_meta_cache = array();
/**
* Prime and return all meta for a snippet post in one call.
@@ -85,7 +85,7 @@
private static function get_snippet_meta( $post_id ) {
$post_id = absint( $post_id );
if ( empty( $post_id ) ) {
- return [];
+ return array();
}
if ( ! isset( self::$post_meta_cache[ $post_id ] ) ) {
@@ -128,7 +128,7 @@
/**
* Get file_based instance (cached) - static version for use in static methods
- *
+ *
* @return object|null File based instance or null
*/
private static function get_file_based_instance_static() {
@@ -145,7 +145,7 @@
/**
* Get file_based instance (cached) - instance method wrapper
- *
+ *
* @return object|null File based instance or null
*/
private function get_file_based_instance() {
@@ -188,7 +188,7 @@
/**
* Get file code list with metadata (cached)
- *
+ *
* @return array File code list with metadata
*/
private function get_file_code_list_with_meta() {
@@ -208,7 +208,7 @@
/**
* Get file code list without metadata (cached)
- *
+ *
* @return array File code list without metadata
*/
private function get_file_code_list_without_meta() {
@@ -277,13 +277,13 @@
$title = sanitize_text_field( wp_unslash( $snippet['name'] ) );
}
- return [
+ return array(
'name' => $title,
'status' => 'publish',
- 'tags' => isset( $snippet['tags'] ) ? $snippet['tags'] : [],
+ 'tags' => isset( $snippet['tags'] ) ? $snippet['tags'] : array(),
'description' => isset( $snippet['description'] ) ? $snippet['description'] : '',
'type' => isset( $snippet['type'] ) ? $snippet['type'] : '',
- 'condition' => [
+ 'condition' => array(
'insertion' => isset( $snippet['insertion'] ) ? $snippet['insertion'] : 'auto',
'css_selector' => isset( $snippet['css_selector'] ) ? $snippet['css_selector'] : '',
'element_index' => isset( $snippet['element_index'] ) ? $snippet['element_index'] : 0,
@@ -297,17 +297,17 @@
'on_ajax_work' => isset( $snippet['on_ajax_work'] ) ? $snippet['on_ajax_work'] : false,
'startDate' => isset( $snippet['startDate'] ) ? $snippet['startDate'] : '',
'endDate' => isset( $snippet['endDate'] ) ? $snippet['endDate'] : '',
- 'shortcodeattr' => isset( $snippet['shortcodeattr'] ) ? $snippet['shortcodeattr'] : [],
+ 'shortcodeattr' => isset( $snippet['shortcodeattr'] ) ? $snippet['shortcodeattr'] : array(),
'html_hooks' => isset( $snippet['htmlHooks'] ) ? $snippet['htmlHooks'] : '',
- 'in-sub-rule' => isset( $snippet['in_sub_data'] ) ? $snippet['in_sub_data'] : [],
- 'ex-sub-rule' => isset( $snippet['ex_sub_data'] ) ? $snippet['ex_sub_data'] : [],
+ 'in-sub-rule' => isset( $snippet['in_sub_data'] ) ? $snippet['in_sub_data'] : array(),
+ 'ex-sub-rule' => isset( $snippet['ex_sub_data'] ) ? $snippet['ex_sub_data'] : array(),
'status' => 0,
- 'smart-logic' => isset( $snippet['smart_conditional_logic'] ) ? $snippet['smart_conditional_logic'] : [],
+ 'smart-logic' => isset( $snippet['smart_conditional_logic'] ) ? $snippet['smart_conditional_logic'] : array(),
'php-hidden-execute' => isset( $snippet['php_hidden_execute'] ) ? $snippet['php_hidden_execute'] : 'no',
// 'always' = never gated; the dispatchers re-check it at output time, so never trust it alone.
'consent_category' => isset( $snippet['consent_category'] ) ? sanitize_key( $snippet['consent_category'] ) : 'always',
- ],
- ];
+ ),
+ );
}
/**
@@ -329,20 +329,20 @@
/**
* Update cache option (optimized)
- *
+ *
* @param string $cache_option Option name
* @return void
*/
private function update_cache_option( $cache_option = 'nxt-build-get-data' ) {
$get_data = get_option( $cache_option );
if ( $get_data === false ) {
- $value = [
+ $value = array(
'saved' => strtotime( 'now' ),
'singular_updated' => '',
'archives_updated' => '',
'sections_updated' => '',
- 'code_updated' => ''
- ];
+ 'code_updated' => '',
+ );
add_option( $cache_option, $value, '', 'yes' );
} elseif ( ! empty( $get_data ) ) {
$get_data['saved'] = strtotime( 'now' );
@@ -352,7 +352,7 @@
/**
* Clear file-based caches
- *
+ *
* @return void
*/
private function clear_file_based_cache() {
@@ -441,9 +441,9 @@
/**
* Sanitize and unslash POST data (optimized helper)
- *
+ *
* @param string $key POST key
- * @param mixed $default Default value if not set
+ * @param mixed $default Default value if not set
* @return mixed Sanitized value
*/
private function sanitize_post( $key, $default = '' ) {
@@ -458,7 +458,7 @@
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
- self::$instance = new self;
+ self::$instance = new self();
}
return self::$instance;
}
@@ -467,11 +467,11 @@
* Constructor
*/
public function __construct() {
-
- //if(!is_admin()){
- // add_action( 'wp', array( $this, 'get_snippet_ids' ), 1 );
- //}
-
+
+ // if(!is_admin()){
+ // add_action( 'wp', array( $this, 'get_snippet_ids' ), 1 );
+ // }
+
// Separate actions for each code type (frontend scope only).
if ( ! is_admin() ) {
add_action( 'wp', array( $this, 'nexter_code_html_hooks_actions' ), 2 );
@@ -480,9 +480,9 @@
// Enqueue CSS/JS for frontend
if ( ! is_admin() ) {
- add_action( 'wp_enqueue_scripts', array( $this, 'nexter_code_snippets_css_js' ),2 );
+ add_action( 'wp_enqueue_scripts', array( $this, 'nexter_code_snippets_css_js' ), 2 );
}
-
+
// Enqueue CSS/JS for admin area (for admin_header and admin_footer locations)
if ( is_admin() ) {
if ( $this->should_boot_admin_snippet_runtime() ) {
@@ -493,11 +493,12 @@
}
// Execute PHP snippets only after request context is available.
- if ( ( ! isset( $_GET['test_code'] ) || empty( $_GET['test_code'] )) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, handled by the core method already.
- //add_action( 'wp', array( $this, 'nexter_php_execution_snippet' ), 1 );
+ if ( ( ! isset( $_GET['test_code'] ) || empty( $_GET['test_code'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, handled by the core method already.
+ // add_action( 'wp', array( $this, 'nexter_php_execution_snippet' ), 1 );
$this->nexter_php_execution_snippet();
-
- /* if ( is_admin() ) {
+
+ /*
+ if ( is_admin() ) {
add_action( 'admin_init', array( $this, 'nexter_php_execution_snippet' ), 1 );
} else {
add_action( 'wp', array( $this, 'nexter_php_execution_snippet' ), 1 );
@@ -506,20 +507,20 @@
if ( is_admin() ) {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_admin' ) );
- add_action( 'wp_ajax_create_code_snippets', array( $this, 'create_new_snippet') );
- add_action( 'wp_ajax_update_edit_code_snippets', array( $this, 'update_edit_snippet') );
- add_action( 'wp_ajax_fetch_code_snippet_list', array( $this, 'fetch_code_list') );
- add_action( 'wp_ajax_fetch_code_snippet_delete', array( $this, 'fetch_code_snippet_delete') );
- add_action( 'wp_ajax_fetch_code_snippet_export', array( $this, 'fetch_code_snippet_export') );
- add_action( 'wp_ajax_fetch_code_snippet_import', array( $this, 'fetch_code_snippet_import') );
- add_action( 'wp_ajax_fetch_code_snippet_status', array( $this, 'fetch_code_snippet_status') );
- add_action( 'wp_ajax_get_edit_snippet_data', array( $this, 'get_edit_snippet_data') );
- add_action( 'wp_ajax_nexter_get_taxonomy_terms', array( $this, 'get_taxonomy_terms_ajax') );
- add_action( 'wp_ajax_nexter_get_authors', array( $this, 'get_authors_ajax') );
- add_action( 'wp_ajax_fetch_snippet_list_for_conditions', array( $this, 'fetch_snippet_list_for_conditions') );
+ add_action( 'wp_ajax_create_code_snippets', array( $this, 'create_new_snippet' ) );
+ add_action( 'wp_ajax_update_edit_code_snippets', array( $this, 'update_edit_snippet' ) );
+ add_action( 'wp_ajax_fetch_code_snippet_list', array( $this, 'fetch_code_list' ) );
+ add_action( 'wp_ajax_fetch_code_snippet_delete', array( $this, 'fetch_code_snippet_delete' ) );
+ add_action( 'wp_ajax_fetch_code_snippet_export', array( $this, 'fetch_code_snippet_export' ) );
+ add_action( 'wp_ajax_fetch_code_snippet_import', array( $this, 'fetch_code_snippet_import' ) );
+ add_action( 'wp_ajax_fetch_code_snippet_status', array( $this, 'fetch_code_snippet_status' ) );
+ add_action( 'wp_ajax_get_edit_snippet_data', array( $this, 'get_edit_snippet_data' ) );
+ add_action( 'wp_ajax_nexter_get_taxonomy_terms', array( $this, 'get_taxonomy_terms_ajax' ) );
+ add_action( 'wp_ajax_nexter_get_authors', array( $this, 'get_authors_ajax' ) );
+ add_action( 'wp_ajax_fetch_snippet_list_for_conditions', array( $this, 'fetch_snippet_list_for_conditions' ) );
}
- //add_action( 'init', array( $this, 'home_page_code_execute' ) );
-
+ // add_action( 'init', array( $this, 'home_page_code_execute' ) );
+
// Initialize CSS selector functionality only on frontend.
if ( ! is_admin() ) {
add_action( 'wp', array( $this, 'init_css_selector_functionality' ), 4 );
@@ -529,38 +530,38 @@
public function nexter_register_snippet_ids_filter() {
add_filter(
'nexter_loaded_snippet_ids',
- function($all) {
+ function ( $all ) {
return array_merge( $all, self::$snippet_loaded_ids );
}
);
}
- public function check_and_recover_html($html) {
+ public function check_and_recover_html( $html ) {
$html = stripslashes( $html );
libxml_use_internal_errors( true );
$dom = new DOMDocument();
-
+
if ( $dom->loadHTML( $html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD ) ) {
$errors = libxml_get_errors();
libxml_clear_errors();
-
+
if ( empty( $errors ) ) {
return '';
} else {
$error_messages = array_map(
- function($error) {
- return [
- 'line' => $error->line,
- 'message' => trim( $error->message )
- ];
+ function ( $error ) {
+ return array(
+ 'line' => $error->line,
+ 'message' => trim( $error->message ),
+ );
},
$errors
);
-
- return ['error' => $error_messages];
+
+ return array( 'error' => $error_messages );
}
} else {
- return ['error' => esc_html__( 'Failed to load HTML. Check syntax.','nexter-extension' )];
+ return array( 'error' => esc_html__( 'Failed to load HTML. Check syntax.', 'nexter-extension' ) );
}
return '';
}
@@ -568,11 +569,11 @@
/**
* Load Snippets get IDs
*/
- public static function get_snippets_ids_list( $type='' ){
+ public static function get_snippets_ids_list( $type = '' ) {
$get_result = array();
if ( self::$snippet_ids && ! empty( $type ) ) {
foreach ( self::$snippet_ids as $post_id => $post_data ) {
-
+
$codes_snippet = get_post_meta( $post_id, 'nxt-code-type', false );
$codes_status = get_post_meta( $post_id, 'nxt-code-status', false );
if ( ! empty( $codes_snippet ) && $codes_snippet[0] == $type && ! empty( $codes_status[0] ) && $codes_status[0] == 1 ) {
@@ -580,17 +581,18 @@
}
}
}
-
+
// Enhanced fallback: If we got results from display rules but they seem incomplete,
// merge with direct database query to ensure all active snippets are included
- /* if (!empty($get_result) && !empty($type)) {
+ /*
+ if (!empty($get_result) && !empty($type)) {
$fallback_results = self::get_snippets_fallback($type);
if (!empty($fallback_results)) {
// Merge and remove duplicates
$get_result = array_unique(array_merge($get_result, $fallback_results));
}
} */
-
+
return $get_result;
}
@@ -620,15 +622,15 @@
// Code Snippet Dashboard enquque
if ( strpos( $hook_suffix, 'nxt_code_snippets' ) === false ) {
return;
- } else if ( ! str_contains( $hook_suffix, 'nxt_code_snippets' ) ) {
+ } elseif ( ! str_contains( $hook_suffix, 'nxt_code_snippets' ) ) {
return;
}
wp_enqueue_style( 'nxt-code-snippet-style', NEXTER_EXT_URL . 'assets/css/admin/nxt-code-snippet.min.css', array(), NEXTER_EXT_VER, 'all' );
- //wp_enqueue_style( 'nxt-code-snippet-style', NEXTER_EXT_URL . 'code-snippets/build/index.css', array(), NEXTER_EXT_VER, 'all' );
+ // wp_enqueue_style( 'nxt-code-snippet-style', NEXTER_EXT_URL . 'code-snippets/build/index.css', array(), NEXTER_EXT_VER, 'all' );
wp_enqueue_script( 'nxt-code-snippet', NEXTER_EXT_URL . 'assets/js/admin/index.js', array( 'react', 'react-dom', 'react-jsx-runtime', 'wp-dom-ready', 'wp-element', 'lodash', 'wp-i18n' ), NEXTER_EXT_VER, true );
- //wp_enqueue_script( 'nxt-code-snippet', NEXTER_EXT_URL . 'code-snippets/build/index.js', array( 'react', 'react-dom', 'react-jsx-runtime', 'wp-dom-ready', 'wp-element','lodash', 'wp-i18n' ), NEXTER_EXT_VER, true );
+ // wp_enqueue_script( 'nxt-code-snippet', NEXTER_EXT_URL . 'code-snippets/build/index.js', array( 'react', 'react-dom', 'react-jsx-runtime', 'wp-dom-ready', 'wp-element','lodash', 'wp-i18n' ), NEXTER_EXT_VER, true );
// Attach JavaScript translations
wp_set_script_translations(
@@ -636,7 +638,7 @@
'nexter-extension', // Your text domain
NEXTER_EXT_DIR . 'languages'
);
- //wp_enqueue_script( 'nxt-code-snippet', NEXTER_EXT_URL . 'code-snippets/build/index.js', array( 'react', 'react-dom', 'react-jsx-runtime', 'wp-dom-ready', 'wp-element','lodash' ), NEXTER_EXT_VER, true );
+ // wp_enqueue_script( 'nxt-code-snippet', NEXTER_EXT_URL . 'code-snippets/build/index.js', array( 'react', 'react-dom', 'react-jsx-runtime', 'wp-dom-ready', 'wp-element','lodash' ), NEXTER_EXT_VER, true );
if ( ! function_exists( 'get_editable_roles' ) ) {
require_once ABSPATH . 'wp-admin/includes/user.php';
@@ -661,23 +663,23 @@
'nonce' => wp_create_nonce( 'nxt-code-snippet' ),
// The dashboard's module switch (nexter_extra_ext_deactivate) checks this one, so the page can turn the module off.
'module_nonce' => wp_create_nonce( 'nexter_admin_nonce' ),
- 'nxt_url' => NEXTER_EXT_URL.'code-snippets/',
+ 'nxt_url' => NEXTER_EXT_URL . 'code-snippets/',
'assets' => NEXTER_EXT_URL . 'assets/',
- 'htmlHooks' => isset( $cached_localize_data['htmlHooks'] ) ? $cached_localize_data['htmlHooks'] : [],
- 'in_ex_option' => isset( $cached_localize_data['in_ex_option'] ) ? $cached_localize_data['in_ex_option'] : [],
- 'user_role' => isset( $cached_localize_data['user_role'] ) ? $cached_localize_data['user_role'] : [],
- 'post_types' => isset( $cached_localize_data['post_types'] ) ? $cached_localize_data['post_types'] : [],
- 'taxonomies' => isset( $cached_localize_data['taxonomies'] ) ? $cached_localize_data['taxonomies'] : [],
- 'page_templates' => isset( $cached_localize_data['page_templates'] ) ? $cached_localize_data['page_templates'] : [],
+ 'htmlHooks' => isset( $cached_localize_data['htmlHooks'] ) ? $cached_localize_data['htmlHooks'] : array(),
+ 'in_ex_option' => isset( $cached_localize_data['in_ex_option'] ) ? $cached_localize_data['in_ex_option'] : array(),
+ 'user_role' => isset( $cached_localize_data['user_role'] ) ? $cached_localize_data['user_role'] : array(),
+ 'post_types' => isset( $cached_localize_data['post_types'] ) ? $cached_localize_data['post_types'] : array(),
+ 'taxonomies' => isset( $cached_localize_data['taxonomies'] ) ? $cached_localize_data['taxonomies'] : array(),
+ 'page_templates' => isset( $cached_localize_data['page_templates'] ) ? $cached_localize_data['page_templates'] : array(),
'whiteLabel' => Nxt_Options::white_label(),
- 'isactivate' => (defined( 'NXT_PRO_EXT' ) && class_exists( 'Nexter_Pro_Ext_Activate' )) ? Nexter_Pro_Ext_Activate::get_instance()->nexter_activate_status() : '',
- 'is_pro' => (defined( 'NXT_PRO_EXT' )) ? true : false,
+ 'isactivate' => ( defined( 'NXT_PRO_EXT' ) && class_exists( 'Nexter_Pro_Ext_Activate' ) ) ? Nexter_Pro_Ext_Activate::get_instance()->nexter_activate_status() : '',
+ 'is_pro' => ( defined( 'NXT_PRO_EXT' ) ) ? true : false,
'ecommerce_plugins' => array(
'woocommerce' => class_exists( 'WooCommerce' ),
'edd' => class_exists( 'Easy_Digital_Downloads' ),
- 'memberpress' => class_exists( 'MeprAppCtrl' )
+ 'memberpress' => class_exists( 'MeprAppCtrl' ),
),
- 'memberpress_memberships' => isset( $cached_localize_data['memberpress_memberships'] ) ? $cached_localize_data['memberpress_memberships'] : [],
+ 'memberpress_memberships' => isset( $cached_localize_data['memberpress_memberships'] ) ? $cached_localize_data['memberpress_memberships'] : array(),
'cs_pro_svg' => NEXTER_EXT_URL . 'assets/images/cs_pro.svg',
'cs_premium_icon' => NEXTER_EXT_URL . 'dashboard/assets/svg/premium_icon.svg',
'cs_ec_required_icon' => NEXTER_EXT_URL . 'assets/images/cs_ec_require.svg',
@@ -700,9 +702,9 @@
}
$data = array(
- 'htmlHooks' => class_exists( 'Nexter_Builder_Display_Conditional_Rules' ) ? Nexter_Builder_Display_Conditional_Rules::get_sections_hooks_options() : [],
- 'in_ex_option' => class_exists( 'Nexter_Builder_Display_Conditional_Rules' ) ? Nexter_Builder_Display_Conditional_Rules::get_location_rules_options() : [],
- 'user_role' => class_exists( 'Nexter_Builder_Display_Conditional_Rules' ) ? Nexter_Builder_Display_Conditional_Rules::get_others_location_sub_options( 'user-roles' ) : [],
+ 'htmlHooks' => class_exists( 'Nexter_Builder_Display_Conditional_Rules' ) ? Nexter_Builder_Display_Conditional_Rules::get_sections_hooks_options() : array(),
+ 'in_ex_option' => class_exists( 'Nexter_Builder_Display_Conditional_Rules' ) ? Nexter_Builder_Display_Conditional_Rules::get_location_rules_options() : array(),
+ 'user_role' => class_exists( 'Nexter_Builder_Display_Conditional_Rules' ) ? Nexter_Builder_Display_Conditional_Rules::get_others_location_sub_options( 'user-roles' ) : array(),
'memberpress_memberships' => $this->get_memberpress_memberships(),
'post_types' => $this->get_dynamic_post_types(),
'taxonomies' => $this->get_dynamic_taxonomies(),
@@ -761,56 +763,56 @@
if ( ! $this->check_permission_user() ) {
wp_send_json_error( __( 'Insufficient permissions.', 'nexter-extension' ) );
}
-
+
check_ajax_referer( 'nxt-code-snippet', 'nonce' );
-
+
$search_query = isset( $_POST['q'] ) ? sanitize_text_field( $_POST['q'] ) : '';
-
+
if ( strlen( $search_query ) < 2 ) {
- wp_send_json( [] );
+ wp_send_json( array() );
return;
}
-
+
$response = array();
-
+
// Get all public taxonomies
- $taxonomies = get_taxonomies( array('public' => true), 'objects' );
-
+ $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
+
foreach ( $taxonomies as $taxonomy ) {
// Skip post format taxonomy
if ( $taxonomy->name === 'post_format' ) {
continue;
}
-
+
// Search for terms in this taxonomy
$terms = get_terms(
array(
- 'taxonomy' => $taxonomy->name,
- 'hide_empty' => false,
- 'name__like' => $search_query,
- 'number' => 20 // Limit results per taxonomy
+ 'taxonomy' => $taxonomy->name,
+ 'hide_empty' => false,
+ 'name__like' => $search_query,
+ 'number' => 20, // Limit results per taxonomy
)
);
-
+
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
$children = array();
-
+
foreach ( $terms as $term ) {
$children[] = array(
'id' => 'term-' . $term->term_id,
- 'text' => $term->name . ' (' . $taxonomy->label . ')'
+ 'text' => $term->name . ' (' . $taxonomy->label . ')',
);
}
-
+
if ( ! empty( $children ) ) {
$response[] = array(
'text' => $taxonomy->label,
- 'children' => $children
+ 'children' => $children,
);
}
}
}
-
+
wp_send_json( $response );
}
@@ -821,47 +823,47 @@
if ( ! $this->check_permission_user() ) {
wp_send_json_error( __( 'Insufficient permissions.', 'nexter-extension' ) );
}
-
+
check_ajax_referer( 'nxt-code-snippet', 'nonce' );
-
+
$search_query = isset( $_POST['q'] ) ? sanitize_text_field( $_POST['q'] ) : '';
-
+
if ( strlen( $search_query ) < 2 ) {
- wp_send_json( [] );
+ wp_send_json( array() );
return;
}
-
+
// Search for users/authors
$users = get_users(
array(
- 'search' => '*' . $search_query . '*',
- 'search_columns' => array('user_login', 'user_nicename', 'display_name', 'user_email'),
- 'number' => 50, // Limit results
- 'orderby' => 'display_name',
- 'order' => 'ASC'
+ 'search' => '*' . $search_query . '*',
+ 'search_columns' => array( 'user_login', 'user_nicename', 'display_name', 'user_email' ),
+ 'number' => 50, // Limit results
+ 'orderby' => 'display_name',
+ 'order' => 'ASC',
)
);
-
+
$response = array();
-
+
if ( ! empty( $users ) ) {
$children = array();
-
+
foreach ( $users as $user ) {
$children[] = array(
- 'id' => 'user-' . $user->ID,
- 'text' => $user->display_name . ' (' . $user->user_login . ')'
+ 'id' => 'user-' . $user->ID,
+ 'text' => $user->display_name . ' (' . $user->user_login . ')',
);
}
-
+
if ( ! empty( $children ) ) {
$response[] = array(
- 'text' => __( 'Authors', 'nexter-extension' ),
- 'children' => $children
+ 'text' => __( 'Authors', 'nexter-extension' ),
+ 'children' => $children,
);
}
}
-
+
wp_send_json( $response );
}
@@ -872,9 +874,9 @@
if ( ! $this->check_permission_user() ) {
wp_send_json_error( __( 'Insufficient permissions.', 'nexter-extension' ) );
}
-
+
check_ajax_referer( 'nxt-code-snippet', 'nonce' );
- $snippet_list = [];
+ $snippet_list = array();
$file_code_list = $this->get_file_code_list_with_meta();
$search_query = isset( $_POST['q'] ) ? sanitize_text_field( $_POST['q'] ) : '';
if ( $file_code_list ) {
@@ -882,15 +884,15 @@
if ( ! empty( $search_query ) && stripos( $code['name'], $search_query ) ===