Plugin Directory

Changeset 2195783


Ignore:
Timestamp:
11/18/2019 04:50:41 PM (6 years ago)
Author:
xyzzyestudioweb
Message:

Integración con Editor Clásico + corrección de errores menores

Location:
xyzzy-basic-seo-analytics
Files:
27 added
3 edited

Legend:

Unmodified
Added
Removed
  • xyzzy-basic-seo-analytics/trunk/inc/functions/admin-meta.php

    r2193881 r2195783  
    4545function xbs_seo_box_html($post) {
    4646
    47     echo '<div id="xbs-keywords-component"></div><br/>';
    48     echo '<div id="xbs-description-component"></div>';
     47    $current_screen = get_current_screen();
    4948
    50     wp_enqueue_script(
    51         'xbs-token-form',
    52         plugins_url( '../../admin/js/token-form.js', __FILE__ ),
    53         array('wp-components', 'wp-data','wp-dom-ready', 'wp-i18n', 'wp-compose')
    54     );
     49    if( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
     50
     51        echo '<div id="xbs-keywords-component"></div><br/>';
     52        echo '<div id="xbs-description-component"></div>';
     53
     54        wp_enqueue_script(
     55            'xbs-token-form',
     56            plugins_url( '../../admin/js/token-form.js', __FILE__ ),
     57            array('wp-components', 'wp-data','wp-dom-ready', 'wp-i18n', 'wp-compose')
     58        );
     59
     60    } else {
     61
     62        // Implementación para editor clásico (sin Gutenberg)
     63
     64        $keywords = '';
     65        $description = '';
     66
     67        if(get_post_meta(get_the_ID(), '_xbs_meta_keywords_field')) {
     68            $keywords = implode(",",get_post_meta(get_the_ID(), '_xbs_meta_keywords_field'));
     69        }
     70
     71        if(get_post_meta(get_the_ID(), '_xbs_meta_description_field')) {
     72            $description = get_post_meta(get_the_ID(), '_xbs_meta_description_field');
     73        }
     74
     75        $keys_placeholder = __('Ej. palabra clave 1, palabra clave 2, palabra clave 3','xbs-lang');
     76        $desc_placeholder = __('Escribe aquí la meta descripción del post','xbs-lang');
     77
     78        echo '<p class="post-attributes-label-wrapper">';
     79        echo '<label class="post-attributes-label" for="xbs_meta_keywords_ng">Palabras clave</label></p>';
     80        echo '<textarea style="width:100%;" rows="4" name="xbs_meta_keywords_ng" placeholder="'. $keys_placeholder . '">'. $keywords .'</textarea>';
     81        echo '<p class="howto" style="margin-top:0px;">10 máximo. Separadas por comas</p>';
     82        echo '<p class="post-attributes-label-wrapper">';
     83        echo '<label class="post-attributes-label" for="xbs_meta_description_ng">Meta descripción</label></p>';
     84        echo '<textarea style="width:100%;" rows="4" name="xbs_meta_description_ng" placeholder="'. $desc_placeholder . '">'. $description[0] .'</textarea>';
     85        echo '<p class="howto" style="margin-top:0px;">Introduce aquí la descripción SEO</p>';
     86    }
    5587}
     88
     89// Implementación para editor clásico (sin Gutenberg)
     90function xbs_save_postdata($post_id)
     91{
     92    if (array_key_exists('xbs_meta_keywords_ng', $_POST)) {
     93       
     94        delete_post_meta($post_id, '_xbs_meta_keywords_field');
     95       
     96        if(!empty($_POST['xbs_meta_keywords_ng'])) {
     97
     98            $keywords_array = explode(",", $_POST['xbs_meta_keywords_ng']);
     99            $total = 0;
     100
     101            foreach($keywords_array as $keyword){
     102               
     103                if(!ctype_space($keyword)) {
     104                    add_post_meta(
     105                        $post_id,
     106                        '_xbs_meta_keywords_field',
     107                        strip_tags(stripslashes($keyword))
     108                    );
     109                }
     110
     111                $total++;
     112                if($total >= 10) { break; }
     113            }
     114        }
     115    }
     116
     117    if (array_key_exists('xbs_meta_description_ng', $_POST)) {
     118        update_post_meta(
     119            $post_id,
     120            '_xbs_meta_description_field',
     121            $_POST['xbs_meta_description_ng']
     122        );
     123    }
     124}
     125add_action('save_post', 'xbs_save_postdata');
    56126
    57127function xbs_set_script_translations() {
  • xyzzy-basic-seo-analytics/trunk/inc/functions/head-embed.php

    r2193881 r2195783  
    3030    endif;
    3131
    32     if(!empty($keywords) && is_single()):
     32    if(!empty($keywords)):
    3333        $html .= '<meta name="keywords" content="' . $keywords . '" />';
    3434        $html .= '<meta name="news_keywords" content="' . $keywords . '" />';
     
    100100    $keywords = '';
    101101
    102     if(!empty(get_post_meta( $id,'_xbs_meta_keywords_field', true))):
     102    if(!is_home() && !empty(get_post_meta( $id,'_xbs_meta_keywords_field', true))):
    103103        $keywords = implode(',', get_post_meta( $id,'_xbs_meta_keywords_field', false));
    104104    elseif(!empty(get_option('xbs_base_keywords'))):
  • xyzzy-basic-seo-analytics/trunk/readme.txt

    r2193937 r2195783  
    44Requires at least: 5.0
    55Tested up to: 5.3
    6 Stable tag: 1.0.0
     6Stable tag: 1.0.1
    77Requires PHP: 5.6
    88License: GPLv2 or later
     
    2727* Este plugin requiere Wordpress 5.0 o superior
    2828* Este plugin requiere PHP 5.6 o superior
    29 * Este plugin requiere Gutenberg activado (no compatible con plugin 'Editor Clásico')
    3029
    3130<strong>Compatibilidad con otros plugins de SEO no testada</strong>
     
    61601. Pantalla de asignación de metadatos base y analytics
    62612. Opciones de agregado de metadatos en páginas, posts y custom post types
     62
     63== Changelog ==
     64
     65= 1.0.1 =
     66* Integración con Editor Clásico
     67* Corrección de errores menores
Note: See TracChangeset for help on using the changeset viewer.