Plugin Directory

Changeset 3061759


Ignore:
Timestamp:
03/31/2024 01:39:34 PM (23 months ago)
Author:
Tkama
Message:

Update to version 1.9.13 from GitHub

Location:
kama-wp-smile
Files:
6 added
2 deleted
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • kama-wp-smile/assets/banner-772x250.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • kama-wp-smile/assets/icon-128x128.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • kama-wp-smile/assets/icon-256x256.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • kama-wp-smile/assets/screenshot-1.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • kama-wp-smile/assets/screenshot-2.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • kama-wp-smile/assets/screenshot-3.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • kama-wp-smile/assets/screenshot-4.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • kama-wp-smile/tags/1.9.13/class.Kama_WP_Smiles.php

    r2484455 r3061759  
    184184    function _smiles_replace_cb( $match ){
    185185
    186         // сначала заменяем полные патерны с названием файла - (:smile:)
     186        // first replace the full paternas with the file name - (:smile:)
    187187        $filename = isset( $match[1] ) ? $match[1] : '';
    188188        if( $filename ){
    189             if( in_array( $filename, $this->get_opt( 'all_sm' ) ) ){
     189            if( in_array( $filename, $this->get_opt( 'all_sm' ), true ) ){
    190190                return sprintf( self::$sm_img, $match[1], $match[1] );
    191191            }
    192             else{
    193                 return '<span title="' . $filename . '.' . $this->get_opt( 'file_ext' ) . ' - no smiley file...">--</span>';
    194             }
    195         }
    196         // теперь специальные обозначения
    197         else{
    198             $hard_sm = $this->get_opt( 'hard_sm' );
    199             if( $hard_sm && isset( $hard_sm[ $match[0] ] ) ){
    200                 return sprintf( self::$sm_img, $hard_sm[ $match[0] ], $hard_sm[ $match[0] ] );
    201             }
     192
     193            return '<span title="' . $filename . '.' . $this->get_opt( 'file_ext' ) . ' - no smiley file...">--</span>';
     194        }
     195
     196        // now special signs
     197        $hard_sm = $this->get_opt( 'hard_sm' );
     198        if( $hard_sm && isset( $hard_sm[ $match[0] ] ) ){
     199            return sprintf( self::$sm_img, $hard_sm[ $match[0] ], $hard_sm[ $match[0] ] );
    202200        }
    203201
     
    206204
    207205    function footer_scripts(){
    208         if( ! is_singular() || ( isset($GLOBALS['post']) && $GLOBALS['post']->comment_status != 'open' ) )
     206        global $post;
     207
     208        if( ( $post && $post->comment_status !== 'open' ) || ! is_singular() ){
    209209            return;
     210        }
    210211
    211212        $all_smile = addslashes( $this->get_all_smile_html( $this->get_opt('textarea_id') ) );
     
    214215        <!-- Kama WP Smiles -->
    215216        <?php echo $this->insert_smile_js(); ?>
    216         <script type="text/javascript">
     217        <script id="kama_wp_smile">
     218        (function(){
    217219            var tx = document.getElementById('<?php echo $this->get_opt('textarea_id') ?>');
    218220            if( tx ){
    219                 var
    220                 txNext = tx.nextSibling,
    221                 txPar  = tx.parentNode,
    222                 txWrapper = document.createElement('DIV');
     221                var txNext = tx.nextSibling;
     222                var txPar = tx.parentNode;
     223                var txWrapper = document.createElement( 'DIV' );
    223224
    224225                txWrapper.innerHTML = '<?php echo $all_smile ?>';
    225                 txWrapper.setAttribute('class', 'kws-wrapper');
    226                 txWrapper.appendChild(tx);
    227                 txWrapper = txPar.insertBefore(txWrapper, txNext);
     226                txWrapper.setAttribute( 'class', 'kws-wrapper' );
     227                txWrapper.appendChild( tx );
     228                txPar.insertBefore( txWrapper, txNext );
    228229            }
     230        })()
    229231        </script>
    230232        <?php
     
    242244            onmouseover="
    243245            var el = this.childNodes[0];
    244             if( el.style.display == \'block\' ) return;
     246            if( el.style.display === \'block\' )
     247                return;
    245248
    246249            el.style.display=\'block\';
     
    297300     * Callback for `wp_head` adds styles.
    298301     */
    299     function styles(){
     302    public function styles(){
    300303
    301304        if( ! is_singular() || $GLOBALS['post']->comment_status !== 'open' ){
     
    306309    }
    307310
    308     function main_css(){
     311    public function main_css(){
    309312        ob_start();
    310313        ?>
     
    389392     * @return array
    390393     */
    391     function get_dir_smile_names( $dir = '' ){
     394    public function get_dir_smile_names( $dir = '' ){
    392395        $out = [];
    393396
    394         if( ! $dir )
     397        if( ! $dir ){
    395398            $dir = $this->pack_path;
     399        }
    396400
    397401        foreach( glob( trailingslashit( $dir ) . '*.{gif,png}', GLOB_BRACE ) as $fpath ){
  • kama-wp-smile/tags/1.9.13/kama_wp_smiles.php

    r2484186 r3061759  
    1111 * Domain Path: /languages
    1212 *
    13  * Requires PHP: 5.4
     13 * Requires PHP: 5.6
    1414 *
    15  * Version: 1.9.12
     15 * Version: 1.9.13
    1616 */
    1717
    18 $data = get_file_data( __FILE__, [ 'ver' =>'Version', 'lang_dir' =>'Domain Path' ] );
     18$data = get_file_data( __FILE__, [ 'ver' => 'Version', 'lang_dir' => 'Domain Path' ] );
    1919
    2020define( 'KWS_VER', $data['ver'] );
     
    2222define( 'KWS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    2323
    24 require_once KWS_PLUGIN_PATH . 'class.Kama_WP_Smiles.php';
     24require_once __DIR__ . '/functions.php';
     25require_once __DIR__ . '/Kama_WP_Smiles.php';
    2526
    2627if( is_admin() && ! defined( 'DOING_AJAX' ) ){
    27     require_once KWS_PLUGIN_PATH . 'class.Kama_WP_Smiles_Admin.php';
     28    require_once __DIR__ . '/Kama_WP_Smiles_Admin.php';
    2829}
    2930
     
    4142
    4243
    43 register_activation_hook( __FILE__, function(){
    44     Kama_WP_Smiles::instance()->activation();
     44register_activation_hook( __FILE__, static function(){
     45    kwsmile()->activation();
    4546} );
    4647
    4748
    48 /**
    49  * Gets plugin instance.
    50  *
    51  * @return Kama_WP_Smiles|Kama_WP_Smiles_Admin
    52  */
    53 function kwsmile(){
    54     return Kama_WP_Smiles::instance();
    55 }
    56 
    57 /**
    58  * Gets smiles HTML for specified textarea.
    59  *
    60  * @param  string $textarea_id textarea ID
    61  * @return string HTML
    62  */
    63 function kws_get_smiles_html( $textarea_id ){
    64     return kwsmile()->get_all_smile_html( $textarea_id ) . kwsmile()->insert_smile_js();
    65 }
    66 
    67 /**
    68  * Convert smiles code to HTML IMG in passed content.
    69  *
    70  * @param  string $content Content where need smiles convert
    71  * @return string Filtered content
    72  */
    73 function kws_convert_smiles( $content ){
    74     return kwsmile()->convert_smilies( $content );
    75 }
    7649
    7750
    78 // DEPRECATED --------------
    79 
    80 function kama_sm_get_smiles_code( $textarea_id ){
    81     _deprecated_function( __FUNCTION__, '1.9.0', 'kws_get_smiles_html()' );
    82 
    83     return kws_get_smiles_html( $textarea_id );
    84 }
    85 
    86 
  • kama-wp-smile/tags/1.9.13/readme.txt

    r2484455 r3061759  
    11=== Kama WP Smiles ===
    2 Stable tag: trunk
    3 Tested up to: 5.6
     2Stable tag: 1.9.13
     3Tested up to: 6.4.3
    44Contributors: Tkama
    5 Official website: http://wp-kama.ru?p=185
    6 Requires at least: 3.0.1
     5Official website: http://wp-kama.ru/185
     6Requires at least: 4.7.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    9 Tags: comments, smiles, posts, optimization
     9Tags: comments, smiles, stickers
    1010
    11 Replace WP smilies (emoticons) to pretty dynamic one. Automaticaly add smiley block to comment form and in visual/HTML editor on admin. You can set your own package of smiles or select preferred from existing list.
     11Replace WordPress emoticons with dynamic smileys, adding a smiley block to comment forms and admin editor. Pick from existing or create custom sets.
    1212
    1313
    1414== Description ==
    1515
    16 Kama WP Smiles adds block with smiles to comment form in your theme and to HTML/visual editor in admin panel. All that allows you easily add smiles into comment or post content. The plugin replace original WordPress emoticons by new pretty dinamic one (gif).
     16Kama WP Smiles enhances your WordPress experience by seamlessly incorporating a smiley block into the comment form of your theme and the HTML/visual editor in the admin panel. This feature simplifies the process of adding smiles to your comments or posts. The plugin replaces the standard WordPress emoticons with lively and animated GIF smileys.
    1717
    18 With Kama WP Smiles visitors of you blog will have easy instrument to add smiles in comments and you will have opportunity to add smiles while writing posts or answer comments.
     18With Kama WP Smiles, visitors to your blog can effortlessly insert smiles into their comments, while you gain the ability to enhance your posts or respond to comments with smiles of your own.
    1919
    20 On plugin settings page, you can choose which of accessible smiles will appear in the smiles block. And you can tune smiles special code like :) which will be replaced on smile image in content. Moreover you can add your own package of any images and use it as smiles.
     20In the plugin settings, you have the option to select which smileys appear in the smiley block. Additionally, you can customize the special codes, such as :) , which trigger the replacement with smiley images in your content. Furthermore, you have the freedom to create and utilize your own set of smiley images.
    2121
    22 If you don't enjoy the plugin, you can just delete it. On uninstall, plugin will clean up after itself.
     22Should you decide the plugin isn't for you, uninstalling it is a breeze. The plugin ensures a clean removal process, leaving no trace behind.
    2323
    24 [Official plugin page](http://wp-kama.ru/?p=185)
     24[Plugin page](http://wp-kama.ru/185)
    2525
    2626
     
    2929== Frequently Asked Questions ==
    3030
    31 = Plugin don't add smile block to comment form =
     31= Plugin don't add smile block for the comment form =
    3232
    33 May be, you comment form textarea HTML tag have not default ID attribute. Specify comment form ID attribute tag on settings page. Default is `comment`
     33Maybe, you comment form textarea HTML tag have not default ID attribute. Specify comment form ID attribute tag on settings page. Default is `comment`
    3434
    3535
     
    6060
    6161
    62 ===== TODO =====
    63 
    64 Поддержка Quick Chat и BbPress
    65 
    66 На мой взгляд - это:
    67 
    68 1. Кнопки (в настройках) > Раскрытие списка смайлов (выпадающий список) > при подведении к значку ИЛИ нажатию на него (или так или так) — (переключатель в настройках!!!)
    69 
    70 — Когда нажимаешь на значок смайла > раскрывается меню > !!! НЕ РЕАЛИЗОВАНО !!!!
    71 (не всегда удобно когда подводишь и раскрывается список, порой даже мешает)
    72 
    73 
    74 2.
    75 — Выпадающий список > наверное тоже самое что пункт 1. только со значком рядом " стрелочка вниз " - (">" только повёрнутая вниз) —---( справа или слева, лучше справа)
    76 
    77 Т.е Отображается смайл и рядом с ним значок (">" только повёрнутая вниз) в виде кнопки (НЕ КРИТИЧНО при полной реализации п.1) - такой переключатель в настройках тоже был бы многим удобен и полезен (или так или так).
    78 
    79 
    80 4.
    81 — Возможность (в настройках плагина) Расширять и сужать сетку смайлов, при раскрытии меню смайлов = отображать количество колонок и столбцов !!!
    82 Т.е - (нажимаешь на смайл или подводишь мышь к нему) = > отображение сетки = (8 столбцов + 16 строк) или (16 столбцов + 16 строк) ..... например (1x2-20) (1-20x1) (2x20) (3x4) (4x3) (5x32) (16x20) итд итп! т.е произвольные параметры в настройках плагина (кол-во столбцов = " X " ; кол-во строк = " X ") !!!
    83 
    84 
    85 8.
    86 - Безопасность:
    87 
    88 /wp-content/plugins/kama-wp-smile/smiles/*.gif
    89 Папки:
    90 /wp-content - есть возможность скрыть с
    91 помощью сторонних плагинов
    92 /plugins/ - есть возможность скрыть с помощью сторонних плагинов
    93 
    94 /kama-wp-smile/smiles/*.gif - Название плагина даёт определить по коду страницы или открытию смайла в новом что установлен wordpress.
    95 
    96 Рекомендую сменить название (Убрать wp из имени папки, .... не плагина!)
    97 - Сделать вообще просто папку Smile или (Kama)
    98 
    99 Например /wp-content/plugins/smile/smiles/*.gif - так точно сразу не определишь!!!
    100 Например /wp-content/plugins/kama/smiles/*.gif - так точно сразу не определишь!!!ъ
    101 т.е будет в коде отображаться /kama/smiles/*.gif
    102 т.е будет в коде отображаться *****/*****/kama/smiles/*.gif
    103 
    104 Спасибо за внимание.
    105 
    106 
    107 
    108 
    10962== Changelog ==
    11063
    11164= 1.9.13 =
     65* UPD: WP Version up.
    11266* NEW: filter `kwsmile__insert_smile_space`.
    11367
  • kama-wp-smile/tags/1.9.13/uninstall.php

    r2461097 r3061759  
    11<?php
    22
    3 if( ! defined('WP_UNINSTALL_PLUGIN') ) exit;
     3defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
    44
    5 if( ! defined('KWS_PLUGIN_PATH') ){
    6     define('KWS_PLUGIN_PATH', plugin_dir_path(__FILE__) );
     5if( ! defined( 'KWS_PLUGIN_PATH' ) ){
     6    define( 'KWS_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
    77
    8     require_once plugin_dir_path(__FILE__) .'class.Kama_WP_Smiles.php';
     8    require_once __DIR__ . '/functions.php';
     9    require_once __DIR__ . '/Kama_WP_Smiles.php';
    910}
    1011
     
    1213
    1314function kws_unistall_init(){
    14     global $wpdb;
    1515
    1616    delete_option( 'kwsmile_version' );
     
    2222
    2323    // delete smiles in content
    24     if(1){
    25 
    26         // collect all names from all folders
    27         $names = array();
    28         foreach( glob(KWS_PLUGIN_PATH .'packs/*') as $dir ){
    29             if( is_dir($dir) )
    30                 $names = array_merge( $names, Kama_WP_Smiles::get_dir_smile_names($dir) );
    31         }
    32         foreach( glob(untrailingslashit(KWS_PLUGIN_PATH) .'-packs/*') as $dir ){
    33             if( is_dir($dir) )
    34                 $names = array_merge( $names, Kama_WP_Smiles::get_dir_smile_names($dir) );
    35         }
    36 
    37         $names = array_unique( $names );
    38 
    39         // split huge number of names into sets by 100
    40         $all_count = count( $names );
    41         $split_names = array();
    42         $start_from = 0; // start
    43         while(true){
    44             $split_names[] = array_slice( $names, $start_from, 100 );
    45 
    46             if( $start_from > $all_count )
    47                 break; // stop
    48 
    49             $start_from += 100;
    50         }
     24    _kws_delete_smiles_in_content();
    5125
    5226
    53         // delete sets
    54         $affected_rows = 0;
    55         foreach( $split_names as $names ){
     27    // delete custom created packs - the folder `/wp-content/plugins/kama-wp-smile-packs`
     28    _kws_delete_folder( untrailingslashit( KWS_PLUGIN_PATH ) . '-packs' );
     29}
    5630
    57             // multiple replace query - REPLACE( REPLACE( REPLACE( __FIELDNAME__, '(:acute:)', ''), '(:aggressive:)', ''), '(:air_kiss:)', '')
    58             $REPLACE_patt = '';
    59             foreach( $names as $val ){
     31function _kws_delete_smiles_in_content(){
     32    global $wpdb;
    6033
    61                 if( $val = preg_replace('/[^a-zA-Z0-9_-]/', '', $val ) ){
    62                     $smile_code = Kama_WP_Smiles::$sm_start . $val . Kama_WP_Smiles::$sm_end;
    63                     $REPLACE_patt = str_replace(
    64                         array( '__FIELDNAME__',                                  '__SMILECODE__' ),
    65                         array( ($REPLACE_patt ? $REPLACE_patt : '__FIELDNAME__'), $smile_code ),
    66                         "REPLACE( __FIELDNAME__, '__SMILECODE__', '')"
    67                     );
    68                 }
    69             }
    70 
    71             if( $REPLACE_patt ){
    72                 $affected_rows += $wpdb->query(
    73                     "UPDATE $wpdb->posts SET post_content = ". str_replace( '__FIELDNAME__', 'post_content', $REPLACE_patt ) ." WHERE post_type NOT IN ('attachment','revision','nav_meny_item')"
    74                 );
    75 
    76                 $affected_rows += $wpdb->query(
    77                     "UPDATE $wpdb->comments SET comment_content = ". str_replace( '__FIELDNAME__', 'comment_content', $REPLACE_patt ) .""
    78                 );
    79             }
    80 
     34    // collect all names from all folders
     35    $names = [];
     36    foreach( glob( KWS_PLUGIN_PATH . 'packs/*' ) as $dir ){
     37        if( is_dir( $dir ) ){
     38            /** @noinspection SlowArrayOperationsInLoopInspection */
     39            $names = array_merge( $names, kwsmile()->get_dir_smile_names( $dir ) );
     40        }
     41    }
     42    foreach( glob( untrailingslashit( KWS_PLUGIN_PATH ) . '-packs/*' ) as $dir ){
     43        if( is_dir( $dir ) ){
     44            /** @noinspection SlowArrayOperationsInLoopInspection */
     45            $names = array_merge( $names, kwsmile()->get_dir_smile_names( $dir ) );
    8146        }
    8247    }
    8348
    84     // delete custom created packs - the folder `/wp-content/plugins/kama-wp-smile-packs`
    85     _kws_delete_folder( untrailingslashit(KWS_PLUGIN_PATH) .'-packs' );
     49    $names = array_unique( $names );
     50
     51    // split huge number of names into sets by 100
     52    $all_count = count( $names );
     53    $split_names = [];
     54    $start_from = 0; // start
     55    while( true ){
     56        $split_names[] = array_slice( $names, $start_from, 100 );
     57
     58        if( $start_from > $all_count ){
     59            break;
     60        }
     61
     62        $start_from += 100;
     63    }
     64
     65    // delete sets
     66    $affected_rows = 0;
     67    foreach( $split_names as $names ){
     68
     69        // multiple replace query - REPLACE( REPLACE( REPLACE( __FIELDNAME__, '(:acute:)', ''), '(:aggressive:)', ''), '(:air_kiss:)', '')
     70        $REPLACE_patt = '';
     71        foreach( $names as $val ){
     72
     73            if( $val = preg_replace( '/[^a-zA-Z0-9_-]/', '', $val ) ){
     74
     75                $smile_code = Kama_WP_Smiles::$sm_start . $val . Kama_WP_Smiles::$sm_end;
     76
     77                $REPLACE_patt = str_replace(
     78                    [ '__FIELDNAME__', '__SMILECODE__' ],
     79                    [ ( $REPLACE_patt ?: '__FIELDNAME__' ), $smile_code ],
     80                    "REPLACE( __FIELDNAME__, '__SMILECODE__', '')"
     81                );
     82            }
     83        }
     84
     85        if( $REPLACE_patt ){
     86            $affected_rows += $wpdb->query( $wpdb->prepare(
     87                "UPDATE $wpdb->posts SET post_content = %s WHERE post_type NOT IN ( 'attachment', 'revision', 'nav_meny_item' )",
     88                str_replace( '__FIELDNAME__', 'post_content', $REPLACE_patt )
     89            ) );
     90
     91            $affected_rows += $wpdb->query( $wpdb->prepare(
     92                "UPDATE $wpdb->comments SET comment_content = %s",
     93                str_replace( '__FIELDNAME__', 'comment_content', $REPLACE_patt )
     94            ) );
     95        }
     96    }
    8697}
    8798
     
    95106
    96107    $glod = glob( "$folder_path/{,.}[!.,!..]*", GLOB_BRACE );
     108
    97109    foreach( $glod as $file ){
    98         if( is_dir($file) )
     110        if( is_dir( $file ) ){
    99111            call_user_func( __FUNCTION__, $file );
    100         else
     112        }
     113        else{
    101114            unlink( $file );
     115        }
    102116    }
    103117
    104     if( $delete_self )
     118    if( $delete_self ){
    105119        rmdir( $folder_path );
     120    }
    106121}
  • kama-wp-smile/trunk/class.Kama_WP_Smiles.php

    r2484455 r3061759  
    184184    function _smiles_replace_cb( $match ){
    185185
    186         // сначала заменяем полные патерны с названием файла - (:smile:)
     186        // first replace the full paternas with the file name - (:smile:)
    187187        $filename = isset( $match[1] ) ? $match[1] : '';
    188188        if( $filename ){
    189             if( in_array( $filename, $this->get_opt( 'all_sm' ) ) ){
     189            if( in_array( $filename, $this->get_opt( 'all_sm' ), true ) ){
    190190                return sprintf( self::$sm_img, $match[1], $match[1] );
    191191            }
    192             else{
    193                 return '<span title="' . $filename . '.' . $this->get_opt( 'file_ext' ) . ' - no smiley file...">--</span>';
    194             }
    195         }
    196         // теперь специальные обозначения
    197         else{
    198             $hard_sm = $this->get_opt( 'hard_sm' );
    199             if( $hard_sm && isset( $hard_sm[ $match[0] ] ) ){
    200                 return sprintf( self::$sm_img, $hard_sm[ $match[0] ], $hard_sm[ $match[0] ] );
    201             }
     192
     193            return '<span title="' . $filename . '.' . $this->get_opt( 'file_ext' ) . ' - no smiley file...">--</span>';
     194        }
     195
     196        // now special signs
     197        $hard_sm = $this->get_opt( 'hard_sm' );
     198        if( $hard_sm && isset( $hard_sm[ $match[0] ] ) ){
     199            return sprintf( self::$sm_img, $hard_sm[ $match[0] ], $hard_sm[ $match[0] ] );
    202200        }
    203201
     
    206204
    207205    function footer_scripts(){
    208         if( ! is_singular() || ( isset($GLOBALS['post']) && $GLOBALS['post']->comment_status != 'open' ) )
     206        global $post;
     207
     208        if( ( $post && $post->comment_status !== 'open' ) || ! is_singular() ){
    209209            return;
     210        }
    210211
    211212        $all_smile = addslashes( $this->get_all_smile_html( $this->get_opt('textarea_id') ) );
     
    214215        <!-- Kama WP Smiles -->
    215216        <?php echo $this->insert_smile_js(); ?>
    216         <script type="text/javascript">
     217        <script id="kama_wp_smile">
     218        (function(){
    217219            var tx = document.getElementById('<?php echo $this->get_opt('textarea_id') ?>');
    218220            if( tx ){
    219                 var
    220                 txNext = tx.nextSibling,
    221                 txPar  = tx.parentNode,
    222                 txWrapper = document.createElement('DIV');
     221                var txNext = tx.nextSibling;
     222                var txPar = tx.parentNode;
     223                var txWrapper = document.createElement( 'DIV' );
    223224
    224225                txWrapper.innerHTML = '<?php echo $all_smile ?>';
    225                 txWrapper.setAttribute('class', 'kws-wrapper');
    226                 txWrapper.appendChild(tx);
    227                 txWrapper = txPar.insertBefore(txWrapper, txNext);
     226                txWrapper.setAttribute( 'class', 'kws-wrapper' );
     227                txWrapper.appendChild( tx );
     228                txPar.insertBefore( txWrapper, txNext );
    228229            }
     230        })()
    229231        </script>
    230232        <?php
     
    242244            onmouseover="
    243245            var el = this.childNodes[0];
    244             if( el.style.display == \'block\' ) return;
     246            if( el.style.display === \'block\' )
     247                return;
    245248
    246249            el.style.display=\'block\';
     
    297300     * Callback for `wp_head` adds styles.
    298301     */
    299     function styles(){
     302    public function styles(){
    300303
    301304        if( ! is_singular() || $GLOBALS['post']->comment_status !== 'open' ){
     
    306309    }
    307310
    308     function main_css(){
     311    public function main_css(){
    309312        ob_start();
    310313        ?>
     
    389392     * @return array
    390393     */
    391     function get_dir_smile_names( $dir = '' ){
     394    public function get_dir_smile_names( $dir = '' ){
    392395        $out = [];
    393396
    394         if( ! $dir )
     397        if( ! $dir ){
    395398            $dir = $this->pack_path;
     399        }
    396400
    397401        foreach( glob( trailingslashit( $dir ) . '*.{gif,png}', GLOB_BRACE ) as $fpath ){
  • kama-wp-smile/trunk/kama_wp_smiles.php

    r2484186 r3061759  
    1111 * Domain Path: /languages
    1212 *
    13  * Requires PHP: 5.4
     13 * Requires PHP: 5.6
    1414 *
    15  * Version: 1.9.12
     15 * Version: 1.9.13
    1616 */
    1717
    18 $data = get_file_data( __FILE__, [ 'ver' =>'Version', 'lang_dir' =>'Domain Path' ] );
     18$data = get_file_data( __FILE__, [ 'ver' => 'Version', 'lang_dir' => 'Domain Path' ] );
    1919
    2020define( 'KWS_VER', $data['ver'] );
     
    2222define( 'KWS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    2323
    24 require_once KWS_PLUGIN_PATH . 'class.Kama_WP_Smiles.php';
     24require_once __DIR__ . '/functions.php';
     25require_once __DIR__ . '/Kama_WP_Smiles.php';
    2526
    2627if( is_admin() && ! defined( 'DOING_AJAX' ) ){
    27     require_once KWS_PLUGIN_PATH . 'class.Kama_WP_Smiles_Admin.php';
     28    require_once __DIR__ . '/Kama_WP_Smiles_Admin.php';
    2829}
    2930
     
    4142
    4243
    43 register_activation_hook( __FILE__, function(){
    44     Kama_WP_Smiles::instance()->activation();
     44register_activation_hook( __FILE__, static function(){
     45    kwsmile()->activation();
    4546} );
    4647
    4748
    48 /**
    49  * Gets plugin instance.
    50  *
    51  * @return Kama_WP_Smiles|Kama_WP_Smiles_Admin
    52  */
    53 function kwsmile(){
    54     return Kama_WP_Smiles::instance();
    55 }
    56 
    57 /**
    58  * Gets smiles HTML for specified textarea.
    59  *
    60  * @param  string $textarea_id textarea ID
    61  * @return string HTML
    62  */
    63 function kws_get_smiles_html( $textarea_id ){
    64     return kwsmile()->get_all_smile_html( $textarea_id ) . kwsmile()->insert_smile_js();
    65 }
    66 
    67 /**
    68  * Convert smiles code to HTML IMG in passed content.
    69  *
    70  * @param  string $content Content where need smiles convert
    71  * @return string Filtered content
    72  */
    73 function kws_convert_smiles( $content ){
    74     return kwsmile()->convert_smilies( $content );
    75 }
    7649
    7750
    78 // DEPRECATED --------------
    79 
    80 function kama_sm_get_smiles_code( $textarea_id ){
    81     _deprecated_function( __FUNCTION__, '1.9.0', 'kws_get_smiles_html()' );
    82 
    83     return kws_get_smiles_html( $textarea_id );
    84 }
    85 
    86 
  • kama-wp-smile/trunk/readme.txt

    r2484455 r3061759  
    11=== Kama WP Smiles ===
    2 Stable tag: trunk
    3 Tested up to: 5.6
     2Stable tag: 1.9.13
     3Tested up to: 6.4.3
    44Contributors: Tkama
    5 Official website: http://wp-kama.ru?p=185
    6 Requires at least: 3.0.1
     5Official website: http://wp-kama.ru/185
     6Requires at least: 4.7.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    9 Tags: comments, smiles, posts, optimization
     9Tags: comments, smiles, stickers
    1010
    11 Replace WP smilies (emoticons) to pretty dynamic one. Automaticaly add smiley block to comment form and in visual/HTML editor on admin. You can set your own package of smiles or select preferred from existing list.
     11Replace WordPress emoticons with dynamic smileys, adding a smiley block to comment forms and admin editor. Pick from existing or create custom sets.
    1212
    1313
    1414== Description ==
    1515
    16 Kama WP Smiles adds block with smiles to comment form in your theme and to HTML/visual editor in admin panel. All that allows you easily add smiles into comment or post content. The plugin replace original WordPress emoticons by new pretty dinamic one (gif).
     16Kama WP Smiles enhances your WordPress experience by seamlessly incorporating a smiley block into the comment form of your theme and the HTML/visual editor in the admin panel. This feature simplifies the process of adding smiles to your comments or posts. The plugin replaces the standard WordPress emoticons with lively and animated GIF smileys.
    1717
    18 With Kama WP Smiles visitors of you blog will have easy instrument to add smiles in comments and you will have opportunity to add smiles while writing posts or answer comments.
     18With Kama WP Smiles, visitors to your blog can effortlessly insert smiles into their comments, while you gain the ability to enhance your posts or respond to comments with smiles of your own.
    1919
    20 On plugin settings page, you can choose which of accessible smiles will appear in the smiles block. And you can tune smiles special code like :) which will be replaced on smile image in content. Moreover you can add your own package of any images and use it as smiles.
     20In the plugin settings, you have the option to select which smileys appear in the smiley block. Additionally, you can customize the special codes, such as :) , which trigger the replacement with smiley images in your content. Furthermore, you have the freedom to create and utilize your own set of smiley images.
    2121
    22 If you don't enjoy the plugin, you can just delete it. On uninstall, plugin will clean up after itself.
     22Should you decide the plugin isn't for you, uninstalling it is a breeze. The plugin ensures a clean removal process, leaving no trace behind.
    2323
    24 [Official plugin page](http://wp-kama.ru/?p=185)
     24[Plugin page](http://wp-kama.ru/185)
    2525
    2626
     
    2929== Frequently Asked Questions ==
    3030
    31 = Plugin don't add smile block to comment form =
     31= Plugin don't add smile block for the comment form =
    3232
    33 May be, you comment form textarea HTML tag have not default ID attribute. Specify comment form ID attribute tag on settings page. Default is `comment`
     33Maybe, you comment form textarea HTML tag have not default ID attribute. Specify comment form ID attribute tag on settings page. Default is `comment`
    3434
    3535
     
    6060
    6161
    62 ===== TODO =====
    63 
    64 Поддержка Quick Chat и BbPress
    65 
    66 На мой взгляд - это:
    67 
    68 1. Кнопки (в настройках) > Раскрытие списка смайлов (выпадающий список) > при подведении к значку ИЛИ нажатию на него (или так или так) — (переключатель в настройках!!!)
    69 
    70 — Когда нажимаешь на значок смайла > раскрывается меню > !!! НЕ РЕАЛИЗОВАНО !!!!
    71 (не всегда удобно когда подводишь и раскрывается список, порой даже мешает)
    72 
    73 
    74 2.
    75 — Выпадающий список > наверное тоже самое что пункт 1. только со значком рядом " стрелочка вниз " - (">" только повёрнутая вниз) —---( справа или слева, лучше справа)
    76 
    77 Т.е Отображается смайл и рядом с ним значок (">" только повёрнутая вниз) в виде кнопки (НЕ КРИТИЧНО при полной реализации п.1) - такой переключатель в настройках тоже был бы многим удобен и полезен (или так или так).
    78 
    79 
    80 4.
    81 — Возможность (в настройках плагина) Расширять и сужать сетку смайлов, при раскрытии меню смайлов = отображать количество колонок и столбцов !!!
    82 Т.е - (нажимаешь на смайл или подводишь мышь к нему) = > отображение сетки = (8 столбцов + 16 строк) или (16 столбцов + 16 строк) ..... например (1x2-20) (1-20x1) (2x20) (3x4) (4x3) (5x32) (16x20) итд итп! т.е произвольные параметры в настройках плагина (кол-во столбцов = " X " ; кол-во строк = " X ") !!!
    83 
    84 
    85 8.
    86 - Безопасность:
    87 
    88 /wp-content/plugins/kama-wp-smile/smiles/*.gif
    89 Папки:
    90 /wp-content - есть возможность скрыть с
    91 помощью сторонних плагинов
    92 /plugins/ - есть возможность скрыть с помощью сторонних плагинов
    93 
    94 /kama-wp-smile/smiles/*.gif - Название плагина даёт определить по коду страницы или открытию смайла в новом что установлен wordpress.
    95 
    96 Рекомендую сменить название (Убрать wp из имени папки, .... не плагина!)
    97 - Сделать вообще просто папку Smile или (Kama)
    98 
    99 Например /wp-content/plugins/smile/smiles/*.gif - так точно сразу не определишь!!!
    100 Например /wp-content/plugins/kama/smiles/*.gif - так точно сразу не определишь!!!ъ
    101 т.е будет в коде отображаться /kama/smiles/*.gif
    102 т.е будет в коде отображаться *****/*****/kama/smiles/*.gif
    103 
    104 Спасибо за внимание.
    105 
    106 
    107 
    108 
    10962== Changelog ==
    11063
    11164= 1.9.13 =
     65* UPD: WP Version up.
    11266* NEW: filter `kwsmile__insert_smile_space`.
    11367
  • kama-wp-smile/trunk/uninstall.php

    r2461097 r3061759  
    11<?php
    22
    3 if( ! defined('WP_UNINSTALL_PLUGIN') ) exit;
     3defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
    44
    5 if( ! defined('KWS_PLUGIN_PATH') ){
    6     define('KWS_PLUGIN_PATH', plugin_dir_path(__FILE__) );
     5if( ! defined( 'KWS_PLUGIN_PATH' ) ){
     6    define( 'KWS_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
    77
    8     require_once plugin_dir_path(__FILE__) .'class.Kama_WP_Smiles.php';
     8    require_once __DIR__ . '/functions.php';
     9    require_once __DIR__ . '/Kama_WP_Smiles.php';
    910}
    1011
     
    1213
    1314function kws_unistall_init(){
    14     global $wpdb;
    1515
    1616    delete_option( 'kwsmile_version' );
     
    2222
    2323    // delete smiles in content
    24     if(1){
    25 
    26         // collect all names from all folders
    27         $names = array();
    28         foreach( glob(KWS_PLUGIN_PATH .'packs/*') as $dir ){
    29             if( is_dir($dir) )
    30                 $names = array_merge( $names, Kama_WP_Smiles::get_dir_smile_names($dir) );
    31         }
    32         foreach( glob(untrailingslashit(KWS_PLUGIN_PATH) .'-packs/*') as $dir ){
    33             if( is_dir($dir) )
    34                 $names = array_merge( $names, Kama_WP_Smiles::get_dir_smile_names($dir) );
    35         }
    36 
    37         $names = array_unique( $names );
    38 
    39         // split huge number of names into sets by 100
    40         $all_count = count( $names );
    41         $split_names = array();
    42         $start_from = 0; // start
    43         while(true){
    44             $split_names[] = array_slice( $names, $start_from, 100 );
    45 
    46             if( $start_from > $all_count )
    47                 break; // stop
    48 
    49             $start_from += 100;
    50         }
     24    _kws_delete_smiles_in_content();
    5125
    5226
    53         // delete sets
    54         $affected_rows = 0;
    55         foreach( $split_names as $names ){
     27    // delete custom created packs - the folder `/wp-content/plugins/kama-wp-smile-packs`
     28    _kws_delete_folder( untrailingslashit( KWS_PLUGIN_PATH ) . '-packs' );
     29}
    5630
    57             // multiple replace query - REPLACE( REPLACE( REPLACE( __FIELDNAME__, '(:acute:)', ''), '(:aggressive:)', ''), '(:air_kiss:)', '')
    58             $REPLACE_patt = '';
    59             foreach( $names as $val ){
     31function _kws_delete_smiles_in_content(){
     32    global $wpdb;
    6033
    61                 if( $val = preg_replace('/[^a-zA-Z0-9_-]/', '', $val ) ){
    62                     $smile_code = Kama_WP_Smiles::$sm_start . $val . Kama_WP_Smiles::$sm_end;
    63                     $REPLACE_patt = str_replace(
    64                         array( '__FIELDNAME__',                                  '__SMILECODE__' ),
    65                         array( ($REPLACE_patt ? $REPLACE_patt : '__FIELDNAME__'), $smile_code ),
    66                         "REPLACE( __FIELDNAME__, '__SMILECODE__', '')"
    67                     );
    68                 }
    69             }
    70 
    71             if( $REPLACE_patt ){
    72                 $affected_rows += $wpdb->query(
    73                     "UPDATE $wpdb->posts SET post_content = ". str_replace( '__FIELDNAME__', 'post_content', $REPLACE_patt ) ." WHERE post_type NOT IN ('attachment','revision','nav_meny_item')"
    74                 );
    75 
    76                 $affected_rows += $wpdb->query(
    77                     "UPDATE $wpdb->comments SET comment_content = ". str_replace( '__FIELDNAME__', 'comment_content', $REPLACE_patt ) .""
    78                 );
    79             }
    80 
     34    // collect all names from all folders
     35    $names = [];
     36    foreach( glob( KWS_PLUGIN_PATH . 'packs/*' ) as $dir ){
     37        if( is_dir( $dir ) ){
     38            /** @noinspection SlowArrayOperationsInLoopInspection */
     39            $names = array_merge( $names, kwsmile()->get_dir_smile_names( $dir ) );
     40        }
     41    }
     42    foreach( glob( untrailingslashit( KWS_PLUGIN_PATH ) . '-packs/*' ) as $dir ){
     43        if( is_dir( $dir ) ){
     44            /** @noinspection SlowArrayOperationsInLoopInspection */
     45            $names = array_merge( $names, kwsmile()->get_dir_smile_names( $dir ) );
    8146        }
    8247    }
    8348
    84     // delete custom created packs - the folder `/wp-content/plugins/kama-wp-smile-packs`
    85     _kws_delete_folder( untrailingslashit(KWS_PLUGIN_PATH) .'-packs' );
     49    $names = array_unique( $names );
     50
     51    // split huge number of names into sets by 100
     52    $all_count = count( $names );
     53    $split_names = [];
     54    $start_from = 0; // start
     55    while( true ){
     56        $split_names[] = array_slice( $names, $start_from, 100 );
     57
     58        if( $start_from > $all_count ){
     59            break;
     60        }
     61
     62        $start_from += 100;
     63    }
     64
     65    // delete sets
     66    $affected_rows = 0;
     67    foreach( $split_names as $names ){
     68
     69        // multiple replace query - REPLACE( REPLACE( REPLACE( __FIELDNAME__, '(:acute:)', ''), '(:aggressive:)', ''), '(:air_kiss:)', '')
     70        $REPLACE_patt = '';
     71        foreach( $names as $val ){
     72
     73            if( $val = preg_replace( '/[^a-zA-Z0-9_-]/', '', $val ) ){
     74
     75                $smile_code = Kama_WP_Smiles::$sm_start . $val . Kama_WP_Smiles::$sm_end;
     76
     77                $REPLACE_patt = str_replace(
     78                    [ '__FIELDNAME__', '__SMILECODE__' ],
     79                    [ ( $REPLACE_patt ?: '__FIELDNAME__' ), $smile_code ],
     80                    "REPLACE( __FIELDNAME__, '__SMILECODE__', '')"
     81                );
     82            }
     83        }
     84
     85        if( $REPLACE_patt ){
     86            $affected_rows += $wpdb->query( $wpdb->prepare(
     87                "UPDATE $wpdb->posts SET post_content = %s WHERE post_type NOT IN ( 'attachment', 'revision', 'nav_meny_item' )",
     88                str_replace( '__FIELDNAME__', 'post_content', $REPLACE_patt )
     89            ) );
     90
     91            $affected_rows += $wpdb->query( $wpdb->prepare(
     92                "UPDATE $wpdb->comments SET comment_content = %s",
     93                str_replace( '__FIELDNAME__', 'comment_content', $REPLACE_patt )
     94            ) );
     95        }
     96    }
    8697}
    8798
     
    95106
    96107    $glod = glob( "$folder_path/{,.}[!.,!..]*", GLOB_BRACE );
     108
    97109    foreach( $glod as $file ){
    98         if( is_dir($file) )
     110        if( is_dir( $file ) ){
    99111            call_user_func( __FUNCTION__, $file );
    100         else
     112        }
     113        else{
    101114            unlink( $file );
     115        }
    102116    }
    103117
    104     if( $delete_self )
     118    if( $delete_self ){
    105119        rmdir( $folder_path );
     120    }
    106121}
Note: See TracChangeset for help on using the changeset viewer.