Plugin Directory

Changeset 3415862


Ignore:
Timestamp:
12/09/2025 11:05:05 PM (4 months ago)
Author:
madebycinza
Message:

cinza grid v1.2.4

Location:
cinza-grid
Files:
27 added
4 edited

Legend:

Unmodified
Added
Removed
  • cinza-grid/trunk/cinza-grid.php

    r3397377 r3415862  
    55 * Plugin URI:        https://cinza.io/plugin/cinza-grid/
    66 * Description:       A minimal grid plugin.
    7  * Version:           1.2.3
     7 * Version:           1.2.4
    88 * Requires at least: 5.2
    99 * Requires PHP:      7.2
     
    4040/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    4141
    42 add_action( 'admin_enqueue_scripts', 'add_script_to_cgrid_cpt' );
    43 function add_script_to_cgrid_cpt() {
     42add_action( 'admin_enqueue_scripts', 'cgrid_add_script_to_cpt' );
     43function cgrid_add_script_to_cpt() {
    4444    global $post_type;
    4545
  • cinza-grid/trunk/includes/backend-cpts.php

    r3397377 r3415862  
    7070}
    7171
    72 add_filter( 'set_custom_edit_cinza_grid_columns', 'set_custom_edit_cgrid_columns' );
    73 function set_custom_edit_cgrid_columns($columns) {
     72add_filter( 'set_custom_edit_cinza_grid_columns', 'cgrid_set_custom_edit_columns' );
     73function cgrid_set_custom_edit_columns($columns) {
    7474        $columns['shortcode'] = __( 'Shortcode', 'cinza-grid' );
    7575        return $columns;
    7676}
    7777
    78 add_action( 'manage_cinza_grid_posts_custom_column' , 'custom_cgrid_column', 10, 2 );
    79 function custom_cgrid_column( $column, $post_id ) {
     78add_action( 'manage_cinza_grid_posts_custom_column' , 'cgrid_custom_column', 10, 2 );
     79function cgrid_custom_column( $column, $post_id ) {
    8080    switch ( $column ) {
    8181        case 'shortcode' :
     
    8585}
    8686
    87 add_filter ( 'manage_cinza_grid_posts_columns', 'add_cgrid_columns', 99, 99 );
    88 function add_cgrid_columns ( $columns ) {
     87add_filter ( 'manage_cinza_grid_posts_columns', 'cgrid_add_columns', 99, 99 );
     88function cgrid_add_columns ( $columns ) {
    8989    unset($columns['title']);
    9090    unset($columns['shortcode']);
     
    115115}
    116116
    117 // Remove CPT from SEO sitemap and set robots to noindex nofollow (for Rank Math SEO plugin)
    118 if ( in_array( 'seo-by-rank-math/rank-math.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    119 
    120     // https://rankmath.com/kb/make-theme-rank-math-compatible/#exclude-post-type-from-sitemap
    121     add_filter( 'rank_math/sitemap/exclude_post_type', function ($exclude, $type) {
    122             if ($type === 'cinza_grid') {
    123                     $exclude = true;
    124             }
    125             return $exclude;
    126     }, 10, 2);
    127 
    128     // https://support.rankmath.com/ticket/cpt-noindex/
    129     add_filter( 'rank_math/frontend/robots', function( $robots ) {
    130         if(get_post_type() == 'cinza_grid' ) {
    131             $robots['index'] = 'noindex';
    132             $robots['follow'] = 'nofollow';
    133         }
    134         return $robots;
    135     });
    136 }
     117// Check if Rank Math SEO plugin is active
     118function cgrid_is_rank_math_active() {
     119     if ( ! function_exists( 'is_plugin_active' ) ) {
     120          require_once ABSPATH . 'wp-admin/includes/plugin.php';
     121     }
     122
     123     return is_plugin_active( 'seo-by-rank-math/rank-math.php' );
     124}
     125
     126// Remove CPT from sitemap and set noindex/nofollow only if Rank Math is active
     127if ( cgrid_is_rank_math_active() ) {
     128
     129     // Exclude CPT from Rank Math sitemap
     130     add_filter(
     131          'rank_math/sitemap/exclude_post_type',
     132          function ( $exclude, $type ) {
     133                if ( 'cinza_grid' === $type ) {
     134                     return true;
     135                }
     136                return $exclude;
     137          },
     138          10,
     139          2
     140     );
     141
     142     // Set robots to noindex/nofollow for this CPT
     143     add_filter(
     144          'rank_math/frontend/robots',
     145          function ( $robots ) {
     146                if ( 'cinza_grid' === get_post_type() ) {
     147                     $robots['index']  = 'noindex';
     148                     $robots['follow'] = 'nofollow';
     149                }
     150                return $robots;
     151          }
     152     );
     153}
     154
    137155
    138156// [Possible future addition] Remove CPT from SEO sitemap (for Yoast SEO plugin)
  • cinza-grid/trunk/includes/backend-shortcodes.php

    r3381619 r3415862  
    160160                    $sort_atts = explode ("/", $sort_line);
    161161
    162                     // CHANGED (Security): escape labels and sanitize class key used in data-sort-by and JS map
     162                    // escape labels and sanitize class key used in data-sort-by and JS map
    163163                    $sort_key_raw = isset($sort_atts[0]) ? trim($sort_atts[0]) : '';
    164164                    $sort_label_raw = isset($sort_atts[1]) ? trim($sort_atts[1]) : '';
     
    186186    // Filter
    187187    $filters = '';
    188     $filters_temp = isset($cgrid_options['cgrid_filters']) ? sanitize_textarea_field($cgrid_options['cgrid_filters']) : ''; // CHANGED (Security): sanitize
     188    $filters_temp = isset($cgrid_options['cgrid_filters']) ? sanitize_textarea_field($cgrid_options['cgrid_filters']) : '';
    189189
    190190    if (!empty($filters_temp)) {
     
    212212                        foreach ($filter_buttons as $filter_button) {
    213213                            $btn_label = trim($filter_button);
    214                             $btn_class = sanitize_html_class( strtolower( preg_replace('/\s+/', '-', $btn_label) ) ); // CHANGED (Security)
     214                            $btn_class = sanitize_html_class( strtolower( preg_replace('/\s+/', '-', $btn_label) ) );
    215215                            $filters .= '<button class="button" id="'. esc_attr($btn_class) .'" data-filter=".'. esc_attr($btn_class) .'">'. esc_html($btn_label) .'</button>';
    216216                        }
     
    397397            $grid_item = preg_replace_callback($pattern_date, function($matches) use ($post) {
    398398                $date_format = $matches[1];
    399                 return esc_html( get_the_date($date_format, $post->ID) ); // CHANGED (Security)
     399                return esc_html( get_the_date($date_format, $post->ID) );
    400400            }, $grid_item);
    401401
     
    404404            $grid_item = preg_replace_callback($pattern_meta, function($matches) use ($post) {
    405405                $meta_field = $matches[1];
    406                 // CHANGED (Security): escape meta values as text
     406                // escape meta values as text
    407407                return esc_html( get_post_meta($post->ID, $meta_field, true) );
    408408            }, $grid_item);
     
    410410            if (!empty($filters_temp)) {
    411411                foreach ($filter_lines as $filter_line) {
    412                     $filter_classes .= filter_meta_replace($post, $filter_line);
     412                    $filter_classes .= cgrid_filter_meta_replace($post, $filter_line);
    413413                }
    414414            }
     
    431431            if (!empty($filters_temp)) {
    432432                foreach ($filter_lines as $filter_line) {
    433                     $filter_classes .= filter_tax_replace($post, $filter_line);
     433                    $filter_classes .= cgrid_filter_tax_replace($post, $filter_line);
    434434                }
    435435            }
     
    476476            $grid_item = preg_replace_callback($pattern_imgurlsize, function($matches) use ($post) {
    477477                $size = $matches[1];
    478                 return esc_url( get_the_post_thumbnail_url($post->ID, $size) ); // CHANGED (Security)
     478                return esc_url( get_the_post_thumbnail_url($post->ID, $size) );
    479479            }, $grid_item);
    480480
     
    501501
    502502            $code2 = array(
    503                 esc_html( get_the_title($post->ID) ),              // CHANGED (Security)
    504                 esc_url( get_permalink($post->ID) ),               // CHANGED (Security)
    505                 sanitize_title( $post->post_name ),                // CHANGED (Security)
    506                 esc_html( get_the_date('F j, Y', $post->ID) ),     // CHANGED (Security)
     503                esc_html( get_the_title($post->ID) ),
     504                esc_url( get_permalink($post->ID) ),
     505                sanitize_title( $post->post_name ),
     506                esc_html( get_the_date('F j, Y', $post->ID) ),
    507507                get_the_post_thumbnail($post->ID,'full'),
    508                 esc_url( get_the_post_thumbnail_url($post->ID,'full') ), // CHANGED (Security)
    509                 wp_kses_post( wpautop( get_post_field('post_content', $post->ID) ) ), // CHANGED (Security)
    510                 esc_html( get_the_excerpt($post->ID) ),            // CHANGED (Security)
     508                esc_url( get_the_post_thumbnail_url($post->ID,'full') ),
     509                wp_kses_post( wpautop( get_post_field('post_content', $post->ID) ) ),
     510                esc_html( get_the_excerpt($post->ID) ),
    511511            );
    512512
     
    520520    // Style
    521521    $style = "<style>";
    522     $style .= css_breakpoint($grid_id, $cgrid_breakpoint_1, $cgrid_columns_1, $cgrid_full_width, $cgrid_height_1, $cgrid_spacing_1);
    523     $style .= css_breakpoint($grid_id, $cgrid_breakpoint_2, $cgrid_columns_2, $cgrid_full_width, $cgrid_height_2, $cgrid_spacing_2);
    524     $style .= css_breakpoint($grid_id, $cgrid_breakpoint_3, $cgrid_columns_3, $cgrid_full_width, $cgrid_height_3, $cgrid_spacing_3);
    525     $style .= css_breakpoint($grid_id, $cgrid_breakpoint_4, $cgrid_columns_4, $cgrid_full_width, $cgrid_height_4, $cgrid_spacing_4);
    526     $style .= css_breakpoint($grid_id, $cgrid_breakpoint_5, $cgrid_columns_5, $cgrid_full_width, $cgrid_height_5, $cgrid_spacing_5);
     522    $style .= cgrid_css_breakpoint($grid_id, $cgrid_breakpoint_1, $cgrid_columns_1, $cgrid_full_width, $cgrid_height_1, $cgrid_spacing_1);
     523    $style .= cgrid_css_breakpoint($grid_id, $cgrid_breakpoint_2, $cgrid_columns_2, $cgrid_full_width, $cgrid_height_2, $cgrid_spacing_2);
     524    $style .= cgrid_css_breakpoint($grid_id, $cgrid_breakpoint_3, $cgrid_columns_3, $cgrid_full_width, $cgrid_height_3, $cgrid_spacing_3);
     525    $style .= cgrid_css_breakpoint($grid_id, $cgrid_breakpoint_4, $cgrid_columns_4, $cgrid_full_width, $cgrid_height_4, $cgrid_spacing_4);
     526    $style .= cgrid_css_breakpoint($grid_id, $cgrid_breakpoint_5, $cgrid_columns_5, $cgrid_full_width, $cgrid_height_5, $cgrid_spacing_5);
    527527    $style .= "</style>";
    528528
     
    531531}
    532532
    533 function filter_meta_replace($post, $filters_temp) {
     533function cgrid_filter_meta_replace($post, $filters_temp) {
    534534    if (strpos($filters_temp, '%meta(') !== false) {
    535535        $meta_start_position   = strpos($filters_temp, "%meta(");
     
    539539        $meta_code_args        = substr($filters_temp, $meta_open_paranthesis+2, $meta_close_paranthesis-$meta_open_paranthesis-3);
    540540        $meta_formatted        = get_post_meta( $post->ID, $meta_code_args, true );
    541         // CHANGED (Security): ensure valid CSS class fragment
     541        // ensure valid CSS class fragment
    542542        $meta_class            = sanitize_html_class( strtolower( preg_replace('/\s+/', '-', $meta_formatted) ) );
    543543        return " " . $meta_class;
     
    545545}
    546546
    547 function filter_tax_replace($post, $filters_temp) {
     547function cgrid_filter_tax_replace($post, $filters_temp) {
    548548    if (strpos($filters_temp, '%tax(') !== false) {
    549549        $tax_start_position   = strpos($filters_temp, "%tax(");
     
    556556            $terms_array = array();
    557557            foreach ( $term_list as $term ) {
    558                 // CHANGED (Security): sanitize per-class
     558                // sanitize per-class
    559559                $terms_array[] = sanitize_html_class( strtolower( preg_replace('/\s+/', '-', $term->name) ) );
    560560            }
     
    565565}
    566566
    567 function css_breakpoint($grid_id, $breakpoint, $col, $full_width, $height, $space) {
     567function cgrid_css_breakpoint($grid_id, $breakpoint, $col, $full_width, $height, $space) {
    568568    $style = "
    569569    @media only screen and (min-width: ". intval($breakpoint) ."px) {";
  • cinza-grid/trunk/readme.txt

    r3397377 r3415862  
    33Tags: grid, post grid, display post, metafizzy, isotope
    44Requires at least: 5.2
    5 Tested up to: 6.8
     5Tested up to: 6.9
    66Requires PHP: 7.2
    7 Stable tag: 1.2.3
     7Stable tag: 1.2.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2424
    2525== Changelog ==
     26
     27= 1.2.4 =
     28*Release Date – 9th December, 2025*
     29
     30* Security fixes
     31* WP 6.9 compatibility test
    2632
    2733= 1.2.3 =
Note: See TracChangeset for help on using the changeset viewer.