Plugin Directory

Changeset 2884250


Ignore:
Timestamp:
03/21/2023 12:32:03 PM (3 years ago)
Author:
peymanseo
Message:

fixed save schema bug & prevent remove "type" attr => 2.1.0

Location:
add-schema-category
Files:
12 added
4 edited

Legend:

Unmodified
Added
Removed
  • add-schema-category/trunk/add-schema-category.php

    r2875874 r2884250  
    55 * Plugin URI:        https://github.com/peymanath/Add-Schema-Category-Wordpress
    66 * Description:       Using this plugin you can add and manage Schema codes to the WordPress category.
    7  * Version:           2.0.0
     7 * Version:           2.1.0
    88 * Requires at least: 6.0.1
    99 * Requires PHP:      7.4
     
    3838        </th>
    3939        <td>
    40             <textarea dir="ltr" name="peymanseo_add_schema_category_code" id="peymanseo_add-cat-schema" style="width:100%;" class="large-text" rows="7"><?= wp_kses($ATH_SCHEMA_DB, array('script' => array())); ?></textarea>
     40            <?php wp_editor(stripslashes($ATH_SCHEMA_DB), "peymanseo_add_schema_category_code", ['media_buttons' => false]); ?>
    4141        </td>
    4242    </tr>
  • add-schema-category/trunk/inc/ATH-output.php

    r2875874 r2884250  
    11<?php defined('ABSPATH') || exit('No see');
    22
    3 add_action('edited_category', 'ATH_SAVE_SCHEMA', 10, 2);
    4 add_action('edited_product_cat', 'ATH_SAVE_SCHEMA', 10, 2);
     3function ATH_SCHEMA()
     4{
     5    $get_peymanseo_schema_category = get_term_meta(get_queried_object_id(), 'peymanseo_schema_category', true);
     6    echo wp_kses($get_peymanseo_schema_category, array('script' => array("type" => array())));
     7}
    58
    6 function ATH_SAVE_SCHEMA($ID)
     9function peymanseo_output_script_end_content($content)
    710{
     11    return $content . get_term_meta(get_queried_object_id(), 'peymanseo_schema_category', true);
     12}
    813
    9     $ATH_POST_META_SCHEMA = wp_kses(
    10         $_POST['peymanseo_add_schema_category_code'],
    11         array('script' => array())
    12     );
     14add_action('category_description', 'peymanseo_output_script_end_content');
     15add_action('the_archive_description', 'peymanseo_output_script_end_content');
    1316
    14     if (strpos($ATH_POST_META_SCHEMA, 'schema.org') !== false) return;
     17if (!class_exists('WooCommerce')) {
    1518
    16     if (isset($ATH_POST_META_SCHEMA) || $ATH_POST_META_SCHEMA !== " ")
    17         update_term_meta($ID, 'peymanseo_schema_category', $ATH_POST_META_SCHEMA);
    18     else
    19         delete_term_meta($ID, 'peymanseo_schema_category');
     19    add_action('woocommerce_archive_description', function ($content) {
     20
     21        if (is_product_category())
     22            echo wp_kses(get_term_meta(get_queried_object_id(), 'peymanseo_schema_category', true), array('script' => array("type" => array())));
     23    });
    2024}
  • add-schema-category/trunk/inc/ATH-save-schema.php

    r2875874 r2884250  
    11<?php defined('ABSPATH') || exit('No see');
    22
    3 function ATH_SCHEMA()
     3add_action('edited_category', 'ATH_SAVE_SCHEMA', 10, 2);
     4add_action('edited_product_cat', 'ATH_SAVE_SCHEMA', 10, 2);
     5
     6function ATH_SAVE_SCHEMA($term_id)
    47{
    5     $get_peymanseo_schema_category = get_term_meta(get_queried_object_id(), 'peymanseo_schema_category', true);
    6     echo wp_kses($get_peymanseo_schema_category, array('script' => array()));
     8    $ATH_POST_META_SCHEMA = wp_kses($_POST['peymanseo_add_schema_category_code'], array('script' => array("type" => array())));
     9
     10    if (isset($ATH_POST_META_SCHEMA))
     11        update_term_meta($term_id, 'peymanseo_schema_category', $ATH_POST_META_SCHEMA);
     12
     13
     14    if ($ATH_POST_META_SCHEMA == '')
     15        delete_term_meta($term_id, 'peymanseo_schema_category');
     16    elseif (strpos($ATH_POST_META_SCHEMA, 'schema.org') !== false)
     17        return;
     18    else
     19        delete_term_meta($term_id, 'peymanseo_schema_category');
    720}
    8 
    9 function peymanseo_output_script_end_content($content)
    10 {
    11     return $content . get_term_meta(get_queried_object_id(), 'peymanseo_schema_category', true);
    12 }
    13 
    14 add_action('category_description', 'peymanseo_output_script_end_content');
    15 add_action('the_archive_description', 'peymanseo_output_script_end_content');
    16 
    17 if (!class_exists('WooCommerce')) {
    18 
    19     add_action('woocommerce_archive_description', function ($content) {
    20 
    21         if (is_product_category())
    22             echo wp_kses(get_term_meta(get_queried_object_id(), 'peymanseo_schema_category', true), array('script' => array()));
    23        
    24     });
    25 }
  • add-schema-category/trunk/readme.txt

    r2877760 r2884250  
    44Requires at least: 7.4
    55Tested up to: 6.1
    6 Stable tag: 2.0.0
     6Stable tag: 2.1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.