Plugin Directory

Changeset 3236611


Ignore:
Timestamp:
02/07/2025 01:44:50 PM (10 months ago)
Author:
tusharimran
Message:

aBlocks Updated to version 1.6.2

Location:
ablocks
Files:
705 added
21 edited

Legend:

Unmodified
Added
Removed
  • ablocks/trunk/ablocks.php

    r3234159 r3236611  
    55 * Requires at least: 6.3
    66 * Requires PHP:      7.4
    7  * Version:           1.6.1
     7 * Version:           1.6.2
    88 * Author:            Academy LMS
    99 * Author URI:        https://ablocks.pro/
     
    4141     */
    4242    private function define_constants() {
    43         define( 'ABLOCKS_VERSION', '1.6.1' );
     43        define( 'ABLOCKS_VERSION', '1.6.2' );
    4444        define( 'ABLOCKS_PLUGIN_SLUG', 'ablocks' );
    4545        define( 'ABLOCKS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
  • ablocks/trunk/includes/blocks/form-builder/actions/email.php

    r3191415 r3236611  
    1616
    1717        $data = $this->generate_email_content( $fields, $line_break );
    18         error_log( $data );
    19 
    2018    }
    2119    public function get_response() {
  • ablocks/trunk/includes/blocks/form-builder/actions/email2.php

    r3191415 r3236611  
    1111    public function __construct( $block ) {
    1212        $this->block = $block;
    13 
    14          error_log( 'calling_from_email2' );
    15         error_log( print_r( $block, true ) );
    1613        $this->response = array(
    1714            'massage' => 'calling_from_email2',
  • ablocks/trunk/includes/blocks/form-builder/actions/submission.php

    r3191415 r3236611  
    1111    public function __construct( $block ) {
    1212        $this->block = $block;
    13 
    14          error_log( 'calling_from_submission' );
    15         error_log( print_r( $block, true ) );
    1613        $this->response = array(
    1714            'massage' => 'calling_from_submission',
  • ablocks/trunk/includes/blocks/form-builder/block.php

    r3212972 r3236611  
    254254            $placeholder_css['color'] = $attributes['inputPlaceholderColor'] . '!important'; // Add !important to override conflicting styles
    255255        }
    256         error_log( print_r( $placeholder_css, true ) );
    257256        return $placeholder_css;
    258257
  • ablocks/trunk/includes/blocks/image/block.php

    r3212972 r3236611  
    7676    public function get_image_css( $attributes, $device = '' ) {
    7777        $css = [];
    78         error_log( print_r( $css, true ) );
    7978        if ( ! empty( $attributes[ 'imgUrl' . $device ] ) ) {
    8079            $css['max-width'] = '100%';
  • ablocks/trunk/includes/blocks/map/block.php

    r3212972 r3236611  
    100100        ob_start();
    101101        ?>
    102         <div data-settings='<?php echo htmlspecialchars( wp_json_encode( $settings ), ENT_QUOTES, 'UTF-8' ); ?>' class="ablocks-map-block"></div>
     102        <div
     103            data-settings='<?php
     104                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     105                echo htmlspecialchars( wp_json_encode( $settings ), ENT_QUOTES, 'UTF-8' );
     106            ?>'
     107            class="ablocks-map-block"
     108        >
     109        </div>
    103110        <?php
    104111        $output = ob_get_clean();
  • ablocks/trunk/includes/blocks/news-ticker/block.php

    r3226863 r3236611  
    216216    function get_ticker_list_styles_css( $attributes, $device = '' ) {
    217217        $ticker_list_styles_css = [];
    218         error_log( print_r( $attributes, true ) );
    219 
    220218        if ( isset( $attributes['tickerListStyle'] ) ) {
    221219            switch ( $attributes['tickerListStyle'] ) {
     
    411409    else :
    412410        ?>
    413         <li><?php echo esc_html( sprintf( __( 'No %s found in the selection', 'ablocks' ), $post_type . 's' ) ); ?></li>
     411        <li>
     412            <?php
     413            // translators: %s is the post type (e.g., 'post', 'page', etc.)
     414            echo esc_html( sprintf( __( 'No %s found in the selection', 'ablocks' ), $post_type . 's' ) );
     415        ?></li>
    414416    <?php endif; ?>
    415417
     
    424426                <div class="ablocks-block-news-ticker--icons">
    425427                    <button class="ablocks-block-news-ticker--icons__prev">
    426                     <svg width="24" height="50" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
    427                                     <path d="M18.119 22.1309C18.2003 22.2122 18.2648 22.3087 18.3088 22.415C18.3528 22.5212 18.3755 22.635 18.3755 22.75C18.3755 22.865 18.3528 22.9788 18.3088 23.085C18.2648 23.1913 18.2003 23.2878 18.119 23.3691C18.0378 23.4504 17.9412 23.5148 17.835 23.5588C17.7288 23.6028 17.615 23.6255 17.5 23.6255C17.385 23.6255 17.2712 23.6028 17.165 23.5588C17.0587 23.5148 16.9622 23.4504 16.8809 23.3691L8.13092 14.6191C8.04957 14.5378 7.98503 14.4413 7.941 14.3351C7.89696 14.2288 7.8743 14.115 7.8743 14C7.8743 13.885 7.89696 13.7712 7.941 13.6649C7.98503 13.5587 8.04957 13.4622 8.13092 13.3809L16.8809 4.63094C17.0451 4.46675 17.2678 4.37451 17.5 4.37451C17.7322 4.37451 17.9549 4.46675 18.119 4.63094C18.2832 4.79512 18.3755 5.01781 18.3755 5.25C18.3755 5.48219 18.2832 5.70488 18.119 5.86906L9.98702 14L18.119 22.1309Z" fill="<?php echo $navigator_color; ?>" />
    428                                 </svg>
     428                        <svg width="24" height="50" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
     429                            <path d="M18.119 22.1309C18.2003 22.2122 18.2648 22.3087 18.3088 22.415C18.3528 22.5212 18.3755 22.635 18.3755 22.75C18.3755 22.865 18.3528 22.9788 18.3088 23.085C18.2648 23.1913 18.2003 23.2878 18.119 23.3691C18.0378 23.4504 17.9412 23.5148 17.835 23.5588C17.7288 23.6028 17.615 23.6255 17.5 23.6255C17.385 23.6255 17.2712 23.6028 17.165 23.5588C17.0587 23.5148 16.9622 23.4504 16.8809 23.3691L8.13092 14.6191C8.04957 14.5378 7.98503 14.4413 7.941 14.3351C7.89696 14.2288 7.8743 14.115 7.8743 14C7.8743 13.885 7.89696 13.7712 7.941 13.6649C7.98503 13.5587 8.04957 13.4622 8.13092 13.3809L16.8809 4.63094C17.0451 4.46675 17.2678 4.37451 17.5 4.37451C17.7322 4.37451 17.9549 4.46675 18.119 4.63094C18.2832 4.79512 18.3755 5.01781 18.3755 5.25C18.3755 5.48219 18.2832 5.70488 18.119 5.86906L9.98702 14L18.119 22.1309Z" fill="<?php echo esc_attr($navigator_color); ?>" />
     430                        </svg>
    429431                    </button>
    430432                    <button class="ablocks-block-news-ticker--icons__pause">
     
    434436                    </button>
    435437                    <button class="ablocks-block-news-ticker--icons__next">
    436                     <svg width="24" height="50" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
    437                     <path d="M19.8691 14.6191L11.1191 23.3691C11.0378 23.4504 10.9413 23.5148 10.835 23.5588C10.7288 23.6028 10.615 23.6255 10.5 23.6255C10.385 23.6255 10.2712 23.6028 10.165 23.5588C10.0587 23.5148 9.96223 23.4504 9.88094 23.3691C9.79964 23.2878 9.73515 23.1913 9.69115 23.085C9.64716 22.9788 9.62451 22.865 9.62451 22.75C9.62451 22.635 9.64716 22.5212 9.69115 22.415C9.73515 22.3087 9.79964 22.2122 9.88094 22.1309L18.013 14L9.88094 5.86906C9.71675 5.70488 9.62451 5.48219 9.62451 5.25C9.62451 5.01781 9.71675 4.79512 9.88094 4.63094C10.0451 4.46675 10.2678 4.37451 10.5 4.37451C10.7322 4.37451 10.9549 4.46675 11.1191 4.63094L19.8691 13.3809C19.9504 13.4622 20.015 13.5587 20.059 13.6649C20.103 13.7712 20.1257 13.885 20.1257 14C20.1257 14.115 20.103 14.2288 20.059 14.3351C20.015 14.4413 19.9504 14.5378 19.8691 14.6191Z" fill="<?php echo $navigator_color; ?>" />
     438                        <svg width="24" height="50" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
     439                            <path d="M19.8691 14.6191L11.1191 23.3691C11.0378 23.4504 10.9413 23.5148 10.835 23.5588C10.7288 23.6028 10.615 23.6255 10.5 23.6255C10.385 23.6255 10.2712 23.6028 10.165 23.5588C10.0587 23.5148 9.96223 23.4504 9.88094 23.3691C9.79964 23.2878 9.73515 23.1913 9.69115 23.085C9.64716 22.9788 9.62451 22.865 9.62451 22.75C9.62451 22.635 9.64716 22.5212 9.69115 22.415C9.73515 22.3087 9.79964 22.2122 9.88094 22.1309L18.013 14L9.88094 5.86906C9.71675 5.70488 9.62451 5.48219 9.62451 5.25C9.62451 5.01781 9.71675 4.79512 9.88094 4.63094C10.0451 4.46675 10.2678 4.37451 10.5 4.37451C10.7322 4.37451 10.9549 4.46675 11.1191 4.63094L19.8691 13.3809C19.9504 13.4622 20.015 13.5587 20.059 13.6649C20.103 13.7712 20.1257 13.885 20.1257 14C20.1257 14.115 20.103 14.2288 20.059 14.3351C20.015 14.4413 19.9504 14.5378 19.8691 14.6191Z" fill="<?php echo esc_attr($navigator_color); ?>" />
     440                        </svg>
    438441                    </button>
    439442                </div>
  • ablocks/trunk/includes/blocks/search/block.php

    r3215788 r3236611  
    344344    public function render_block_content( $attributes, $content, $block_instance ) {
    345345
    346         $currentPostID = $attributes['currentPostID'] ?? '';
    347         $source = $attributes['source'] ?? '';
    348         $placeholder = $attributes['placeholder'] ?? 'Write anything.......';
    349         $variant = $attributes['variant'] ?? 'classic';
    350         $isIcon = $attributes['isIcon'] ?? 'icon';
    351         $buttonText = $attributes['buttonText'] ?? 'Search';
    352         $buttonAlignment = $attributes['buttonAlignment']['value'] ?? 'left';
    353 
     346        // Sanitize and escape input attributes
     347        $currentPostID = isset( $attributes['currentPostID'] ) ? (int) sanitize_text_field( $attributes['currentPostID'] ) : '';
     348        $source = isset( $attributes['source'] ) ? sanitize_text_field( $attributes['source'] ) : '';
     349        $placeholder = isset( $attributes['placeholder'] ) ? sanitize_text_field( $attributes['placeholder'] ) : esc_html__('Write anything...', 'ablocks');
     350        $variant = isset( $attributes['variant'] ) ? sanitize_key( $attributes['variant'] ) : 'classic';
     351        $isIcon = isset( $attributes['isIcon'] ) ? sanitize_key( $attributes['isIcon'] ) : 'icon';
     352        $buttonText = isset( $attributes['buttonText'] ) ? sanitize_text_field( $attributes['buttonText'] ) : esc_html__('Search', 'ablocks');
     353        $buttonAlignment = isset( $attributes['buttonAlignment']['value'] ) ? sanitize_key( $attributes['buttonAlignment']['value'] ) : 'left';
     354   
    354355        ob_start();
    355356        ?>
    356357        <div class="ablocks-block--search-bar <?php echo esc_attr( $variant ); ?>">
    357358            <form method="post" class="ablocks-block--search-form <?php echo esc_attr( ( $isIcon === 'both' || $isIcon === 'text' ) ? $isIcon : '' ); ?>">
    358                 <?php if ( $buttonAlignment === 'left' && $variant != 'classic' ) : ?>
     359                <?php if ( 'left' === $buttonAlignment && 'classic' !== $variant ) : ?>
    359360                    <button type="button" class="ablocks-block--search-button <?php echo esc_attr( ( $isIcon === 'both' || $isIcon === 'text' ) ? $isIcon : '' ); ?>">
    360                     <span class="button-content">
    361                         <?php echo $this->render_button( $isIcon, $buttonText ); ?>
    362                     </span>
    363                     <span class="loading-spinner">
    364                         <?php echo $this->loading_spinner(); ?>
    365                     </span>
     361                        <span class="button-content">
     362                            <?php
     363                                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     364                                echo $this->render_button( $isIcon, $buttonText );
     365                            ?>
     366                        </span>
     367                        <span class="loading-spinner">
     368                            <?php
     369                                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     370                                echo $this->loading_spinner();
     371                            ?>
     372                        </span>
    366373                    </button>
    367374                <?php endif; ?>
    368 
    369375                <input class="ablocks-block--search-input <?php echo esc_attr( ( $isIcon === 'both' || $isIcon === 'text' ) ? $isIcon : '' ); ?>" type="text" placeholder="<?php echo esc_attr( $placeholder ); ?>" value=""/>
    370 
    371                 <?php if ( $buttonAlignment === 'right' || $variant === 'classic' ) : ?>
     376                <?php if ( 'right' === $buttonAlignment || 'classic' === $variant ) : ?>
    372377                    <button type="button" class="ablocks-block--search-button <?php echo esc_attr( ( $isIcon === 'both' || $isIcon === 'text' ) ? $isIcon : '' ); ?>">
    373378                        <span class="button-content">
    374                             <?php echo $this->render_button( $isIcon, $buttonText ); ?>
     379                            <?php
     380                                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     381                                echo $this->render_button( $isIcon, $buttonText );
     382                            ?>
    375383                        </span>
    376                         <span class="loading-spinner" >
    377                             <?php echo $this->loading_spinner(); ?>
     384                        <span class="loading-spinner">
     385                            <?php
     386                                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     387                                echo $this->loading_spinner();
     388                            ?>
    378389                        </span>
    379390                    </button>
     
    389400        return ob_get_clean();
    390401    }
    391 
     402   
     403   
    392404    private function render_button( $isIcon, $buttonText ) {
    393405        $search_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search">
     
    395407                            <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
    396408                        </svg>';
    397         if ( $isIcon === 'icon' ) {
     409   
     410        if ( 'icon' === $isIcon ) {
    398411            return $search_icon;
    399         } elseif ( $isIcon === 'text' ) {
     412        } elseif ( 'text' === $isIcon ) {
    400413            return '<span>' . esc_html( $buttonText ) . '</span>';
    401414        } else {
     
    403416        }
    404417    }
    405 
     418   
    406419    private function loading_spinner() {
    407420        $spinner = '<svg viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg">
     
    411424                stroke-linecap="round" />
    412425            </svg>';
    413             return $spinner;
    414     }
    415 
    416 
    417 
    418 
    419 
    420 
    421 
    422 
     426        return $spinner;
     427    }
    423428}
    424429
  • ablocks/trunk/includes/blocks/table-of-content/block.php

    r3212972 r3236611  
    160160
    161161    public function render_block_content( $attributes, $content, $block_instance ) {
    162 
    163162        $post = get_post();
    164163        if ( ! $post ) {
    165164            return '';
    166165        }
    167 
     166   
    168167        add_filter( 'the_content', [ $this, 'add_toc_to_post_content' ] );
    169 
     168   
     169        // Sanitize and escape icon attributes
    170170        $open_icon_attributes = array(
    171             'path' => $attributes['openIconSvgPath'],
    172             'viewBox' => $attributes['openIconSvgViewBox'],
    173             'className' => $attributes['openIconClass'],
    174             'width' => '20',
    175             'height' => '20',
     171            'path'      => esc_attr( $attributes['openIconSvgPath'] ),
     172            'viewBox'   => esc_attr( $attributes['openIconSvgViewBox'] ),
     173            'className' => esc_attr( $attributes['openIconClass'] ),
     174            'width'     => '20',
     175            'height'    => '20',
    176176        );
    177177        $close_icon_attributes = array(
    178             'path' => $attributes['closeIconSvgPath'],
    179             'viewBox' => $attributes['closeIconSvgViewBox'],
    180             'className' => $attributes['closeIconClass'],
    181             'width' => '20',
    182             'height' => '20',
    183         );
    184 
     178            'path'      => esc_attr( $attributes['closeIconSvgPath'] ),
     179            'viewBox'   => esc_attr( $attributes['closeIconSvgViewBox'] ),
     180            'className' => esc_attr( $attributes['closeIconClass'] ),
     181            'width'     => '20',
     182            'height'    => '20',
     183        );
     184   
    185185        $post_content = $post->post_content;
    186186        preg_match_all( '/<h([1-6])[^>]*>(.*?)<\/h\1>/', $post_content, $matches, PREG_SET_ORDER );
    187187        $toc = '';
     188   
     189        // Build TOC header
    188190        if ( (bool) $attributes['hideTitle'] === true ) :
    189191            $toc = '<div class="ablocks-toc__header">';
    190             $toc  .= '<span class="ablocks-toc__header-title">' . esc_html( $attributes['tocTableTitle'] ) . '</span>';
     192            $toc .= '<span class="ablocks-toc__header-title">' . esc_html( $attributes['tocTableTitle'] ) . '</span>';
    191193            if ( $attributes['collapSible'] ) :
    192                 $toc .= '<div class="ablocks-toc__header-toggle-icon"  ><span class="ablocks-toc__show">' . Helper::render_svg_icon_using_attr( $close_icon_attributes ) . '</span> <span class="ablocks-toc__hide">' . Helper::render_svg_icon_using_attr( $open_icon_attributes ) . '</span></div>';
    193         endif;
     194                $toc .= '<div class="ablocks-toc__header-toggle-icon">';
     195                $toc .= '<span class="ablocks-toc__show">' . Helper::render_svg_icon_using_attr( $close_icon_attributes ) . '</span>';
     196                $toc .= '<span class="ablocks-toc__hide">' . Helper::render_svg_icon_using_attr( $open_icon_attributes ) . '</span>';
     197                $toc .= '</div>';
     198            endif;
    194199            $toc .= '</div>';
    195200        endif;
     201   
    196202        $headings = [];
    197         $unique_anchors  = [];
    198 
     203        $unique_anchors = [];
     204   
     205        // Process headings
    199206        foreach ( $matches as $match ) {
    200207            $level = intval( $match[1] );
     
    203210            $anchor = $base_anchor;
    204211            $count = 1;
    205 
     212   
     213            // Ensure unique anchors
    206214            while ( in_array( $anchor, $unique_anchors, true ) ) {
    207215                $anchor = $base_anchor . '-' . $count;
    208216                $count++;
    209217            }
    210 
     218   
     219            // Add heading if enabled in attributes
    211220            if ( ( ( $level === 1 && $attributes['H1'] ) ||
    212                 ( $level === 2 && $attributes['H2'] ) ||
    213                 ( $level === 3 && $attributes['H3'] ) ||
    214                 ( $level === 4 && $attributes['H4'] ) ||
    215                 ( $level === 5 && $attributes['H5'] ) ||
    216                 ( $level === 6 && $attributes['H6'] ) ) ) {
    217 
     221                   ( $level === 2 && $attributes['H2'] ) ||
     222                   ( $level === 3 && $attributes['H3'] ) ||
     223                   ( $level === 4 && $attributes['H4'] ) ||
     224                   ( $level === 5 && $attributes['H5'] ) ||
     225                   ( $level === 6 && $attributes['H6'] ) ) ) {
     226   
    218227                $headings[] = [
    219                     'level' => $level,
    220                     'heading' => $heading,
    221                     'anchor' => $anchor
     228                    'level'   => $level,
     229                    'heading' => esc_html( $heading ),
     230                    'anchor'  => esc_attr( $anchor ),
    222231                ];
    223232                $unique_anchors[] = $anchor;
    224233            }
    225         }//end foreach
    226 
     234        }
     235   
     236        // Build TOC body
    227237        $toc .= '<div class="ablocks-toc-body">';
    228238        $toc .= $this->generate_toc_list( $attributes, $headings );
    229239        $toc .= '</div>';
     240   
    230241        return $toc;
    231242    }
    232 
    233 
     243   
    234244    private function generate_toc_list( $attributes, $headings ) {
     245        if ( empty( $headings ) ) {
     246            return '';
     247        }
     248   
    235249        $toc = '';
     250        $marker_view = in_array( $attributes['markerView'], [ 'ul', 'ol' ], true ) ? $attributes['markerView'] : 'ul';
    236251        $current_level = 0;
    237252        $open_lists = [];
    238 
    239         foreach ( $headings as $heading ) {
    240 
    241             if ( ! isset( $heading['level'] ) || ! isset( $heading['heading'] ) || ! isset( $heading['anchor'] ) ) {
     253   
     254        foreach ( $headings as $index => $heading ) {
     255            if ( ! isset( $heading['level'], $heading['heading'], $heading['anchor'] ) ) {
    242256                continue;
    243257            }
    244 
    245             $level = $heading['level'];
    246 
    247             if ( $level > $current_level ) {
    248                 while ( $current_level < $level ) {
    249                     $toc .= '<' . $attributes['markerView'] . ' class="ablocks-toc-list">';
    250                     $open_lists[] = $attributes['markerView'];
    251                     $current_level++;
    252                 }
    253             }
    254 
    255             while ( $current_level > $level ) {
    256                 $toc .= '</' . array_pop( $open_lists ) . '>';
     258   
     259            $level = (int) $heading['level'];
     260   
     261            // If the first item, open the root list
     262            if ( $index === 0 ) {
     263                $toc .= '<' . esc_attr( $marker_view ) . ' class="ablocks-toc-list">';
     264                $open_lists[] = $marker_view;
     265                $current_level = $level;
     266            }
     267   
     268            // If deeper heading level, open a nested list
     269            while ( $level > $current_level ) {
     270                $toc .= '<' . esc_attr( $marker_view ) . ' class="ablocks-toc-list">';
     271                $open_lists[] = $marker_view;
     272                $current_level++;
     273            }
     274   
     275            // If shallower heading level, close open lists
     276            while ( $level < $current_level ) {
     277                $toc .= '</' . esc_attr( array_pop( $open_lists ) ) . '>';
    257278                $current_level--;
    258279            }
    259 
    260             $toc .= '<li class="ablocks-toc-item"><a class="ablocks-toc-item-link" href="#' . esc_attr( $heading['anchor'] ) . '">' . esc_html( $heading['heading'] ) . '</a></li>';
    261         }//end foreach
    262 
     280   
     281            // Close previous <li> before adding a new one (except for the first)
     282            if ( $index > 0 ) {
     283                $toc .= '</li>';
     284            }
     285   
     286            // Add list item
     287            $toc .= '<li class="ablocks-toc-item">';
     288            $toc .= '<a class="ablocks-toc-item-link" href="#' . esc_attr( $heading['anchor'] ) . '">' . esc_html( $heading['heading'] ) . '</a>';
     289        }
     290   
    263291        // Close any remaining open lists
    264292        while ( ! empty( $open_lists ) ) {
    265             $toc .= '</' . array_pop( $open_lists ) . '>';
    266         }
    267 
     293            $toc .= '</li></' . esc_attr( array_pop( $open_lists ) ) . '>';
     294        }
     295   
    268296        return $toc;
    269297    }
     298   
     299   
     300   
     301   
     302   
    270303
    271304
  • ablocks/trunk/includes/classes/abstract-ajax-handler.php

    r3191415 r3236611  
    2222
    2323    public function handle_ajax_request() {
    24         $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
     24        $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash($_REQUEST['action']) ) : '';
    2525        $action = explode( $this->namespace . '/', $action )[1];
    2626        if ( ! isset( $this->actions[ $action ] ) ) {
     
    3030        $details = $this->actions[ $action ];
    3131
    32         $nonce = isset( $_REQUEST['security'] ) ? sanitize_text_field( $_REQUEST['security'] ) : '';
     32        $nonce = isset( $_REQUEST['security'] ) ? sanitize_text_field( wp_unslash($_REQUEST['security']) ) : '';
    3333        if ( empty( $nonce ) && isset( $_REQUEST['_wpnonce'] ) ) {
    34             $nonce = sanitize_text_field( $_REQUEST['_wpnonce'] );
     34            $nonce = sanitize_text_field( wp_unslash($_REQUEST['_wpnonce']) );
    3535        }
    3636        if ( ! wp_verify_nonce( $nonce, $this->nonce_action ) ) {
  • ablocks/trunk/includes/classes/abstract-post-handler.php

    r3154675 r3236611  
    1919
    2020    public function handle_admin_post_request() {
    21         $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
     21        $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash($_REQUEST['action']) ) : '';
    2222        $action = explode( $this->namespace . '/', $action )[1];
    2323        if ( ! isset( $this->actions[ $action ] ) ) {
     
    2727        $details = $this->actions[ $action ];
    2828
    29         $nonce = isset( $_REQUEST['security'] ) ? sanitize_text_field( $_REQUEST['security'] ) : '';
     29        $nonce = isset( $_REQUEST['security'] ) ? sanitize_text_field( wp_unslash($_REQUEST['security']) ) : '';
    3030        if ( empty( $nonce ) && isset( $_REQUEST['_wpnonce'] ) ) {
    31             $nonce = sanitize_text_field( $_REQUEST['_wpnonce'] );
     31            $nonce = sanitize_text_field( wp_unslash($_REQUEST['_wpnonce']) );
    3232        }
    3333        if ( ! wp_verify_nonce( $nonce, $this->nonce_action ) ) {
  • ablocks/trunk/includes/classes/assets-generator.php

    r3172871 r3236611  
    142142        ];
    143143
     144        // Get WordPress filesystem instance
     145        if ( ! function_exists( 'request_filesystem_credentials' ) ) {
     146            require_once ABSPATH . '/wp-admin/includes/file.php';
     147        }
     148
    144149        if ( ! file_exists( $destination_folder ) ) {
    145150            wp_mkdir_p( $destination_folder );
     
    157162        $valid_extensions = [ 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp' ];
    158163
     164        // Ensure WP_Filesystem is initialized
     165        if ( ! is_object( $GLOBALS['wp_filesystem'] ) ) {
     166            request_filesystem_credentials( '', '', true );
     167        }
     168   
     169        // Initialize the WP_Filesystem object
     170        $wp_filesystem = $GLOBALS['wp_filesystem'];
     171   
     172        // Open the source directory
    159173        $dir = opendir( $source );
    160         @mkdir( $destination ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    161 
    162         while ( false !== ( $file = readdir( $dir ) ) ) { // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
     174   
     175        // Create the destination directory using WP_Filesystem
     176        if ( ! $wp_filesystem->is_dir( $destination ) ) {
     177            $wp_filesystem->mkdir( $destination );
     178        }
     179   
     180        // Loop through files and directories in the source
     181        while ( false !== ( $file = readdir( $dir ) ) ) {
    163182            if ( ( $file !== '.' ) && ( $file !== '..' ) ) {
    164183                $source_file_path = $source . '/' . $file;
    165184                $destination_file_path = $destination . '/' . $file;
    166 
     185   
    167186                // If it's a directory, recursively copy its contents
    168187                if ( is_dir( $source_file_path ) ) {
     
    171190                    // Get file extension
    172191                    $file_extension = pathinfo( $file, PATHINFO_EXTENSION );
    173 
     192   
    174193                    // Check if the file has a valid image extension
    175194                    if ( in_array( strtolower( $file_extension ), $valid_extensions, true ) ) {
    176195                        // Copy only image files
    177                         copy( $source_file_path, $destination_file_path );
     196                        $wp_filesystem->copy( $source_file_path, $destination_file_path );
    178197                    }
    179198                }
    180199            }
    181200        }
     201   
     202        // Close the directory handle
    182203        closedir( $dir );
    183204    }
     205   
    184206}
  • ablocks/trunk/includes/classes/file-upload.php

    r3159931 r3236611  
    1010
    1111    public function upload_file( $file, $supported_file_types = [] ) {
     12        global $wp_filesystem;
     13        if ( empty( $wp_filesystem ) ) {
     14            require_once ABSPATH . '/wp-admin/includes/file.php';
     15            WP_Filesystem();
     16        }
     17
    1218        if ( ! empty( $file ) && ! empty( $file['name'] ) ) {
    1319            $filename = $file['name'];
     
    4147        }
    4248
    43         rename( $upload_file['file'], $this->get_file_path( $filename ) );
     49        $wp_filesystem->move( $upload_file['file'], $destination_path );
    4450
    4551        $file_data  = $this->get_file_data( $filename );
  • ablocks/trunk/includes/controls/background-overlay.php

    r3231348 r3236611  
    353353            $attribute_value
    354354        );
    355         error_log( print_r( $extra_border_value, true ) );
    356355        // Get the units for X and Y position hover states and display size hover width
    357356        $unit_x_position_unit_h = self::get_unit(
  • ablocks/trunk/includes/controls/transform.php

    r3231348 r3236611  
    227227        if ( $value[ 'rotate3D' . $device ] !== false ) {
    228228            $rotation = ! empty( $value[ 'rotate' . $device ] ) ? $value[ 'rotate' . $device ] : 0;
    229             error_log( print_r( $rotation, true ) );
    230229            $transformations[] = 'rotateZ(' . $rotation . 'deg)';
    231230        }
  • ablocks/trunk/includes/helper.php

    r3226863 r3236611  
    202202            } elseif ( isset( $_GET['post'] ) ) {
    203203                // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    204                 $queried_post_type = get_post_type( $_GET['post'] );
     204                $queried_post_type = get_post_type( sanitize_text_field(wp_unslash($_GET['post'])) );
    205205                if ( $queried_post_type === $post_type ) {
    206206                    return true;
  • ablocks/trunk/includes/import/wp-import.php

    r3226863 r3236611  
    938938                unlink( $tmp_file_name );
    939939            }
    940 
     940           
     941            // Translators: %s is the file size limit for the remote file import
    941942            return new WP_Error( 'import_file_error', sprintf( __( 'Remote file is too large, limit is %s', 'ablocks' ), size_format( $max_size ) ) );
    942943        }
  • ablocks/trunk/includes/traits/importer.php

    r3226863 r3236611  
    9191        ob_end_clean();
    9292
     93        // Delete the temporary file if it exists using wp_delete_file.
    9394        if ( file_exists( $tmp_file ) ) {
    94             unlink( $tmp_file );
     95            wp_delete_file( $tmp_file );
    9596        }
    9697
  • ablocks/trunk/readme.txt

    r3234159 r3236611  
    55Tested up to: 6.7
    66Requires PHP: 7.4
    7 Stable tag: 1.6.1
     7Stable tag: 1.6.2
    88License: GPLv3
    99License URI: https://opensource.org/licenses/GPL-3.0
     
    144144== Changelog ==
    145145
     146= 1.6.2 - 07/02/2025 =
     147* Fixed - PCP Plugin Issue
     148
    146149= 1.6.1 - 03/02/2025 =
    147 * Fixed - Container Block Fullwidth, alignment and width issue
     150* Fixed - Container Block Full width, alignment and width issue
    148151* Fixed - Transform Unit Select issue
    149152* Improved - Every Block ID saving logic
  • ablocks/trunk/templates/search-block/search-result-template.php

    r3191415 r3236611  
    44    <a href="<?php echo esc_url( $link ); ?>"> <img class="ablocks-block--search-result__list-thumbnail" src="<?php echo esc_url( $thumbnail ); ?>" alt="<?php echo esc_attr( $title ); ?>"></a>
    55    <?php else : ?>
    6     <a href="<?php echo esc_url( $link ); ?>"><img class="ablocks-block--search-result__list-thumbnail" src="<?php echo ABLOCKS_ASSETS_URL . 'images/search.png'; ?>"></a>
     6    <a href="<?php echo esc_url( $link ); ?>"><img class="ablocks-block--search-result__list-thumbnail" src="<?php echo esc_url(ABLOCKS_ASSETS_URL . 'images/search.png'); ?>"></a>
    77    <?php endif; ?>
    88    <a class="ablocks-block--search-result__list-title" href="<?php echo esc_url( $link ); ?>"><?php echo esc_html( $title ); ?></a>
Note: See TracChangeset for help on using the changeset viewer.