Changeset 3282892
- Timestamp:
- 04/27/2025 07:39:58 PM (10 months ago)
- Location:
- kama-clic-counter
- Files:
-
- 26 edited
- 1 copied
-
tags/4.0.2 (copied) (copied from kama-clic-counter/trunk)
-
tags/4.0.2/admin/pages/_edit-link.php (modified) (4 diffs)
-
tags/4.0.2/kama_click_counter.php (modified) (3 diffs)
-
tags/4.0.2/readme.txt (modified) (5 diffs)
-
tags/4.0.2/src/Admin.php (modified) (11 diffs)
-
tags/4.0.2/src/Content_Replacer.php (modified) (2 diffs)
-
tags/4.0.2/src/Counter.php (modified) (8 diffs)
-
tags/4.0.2/src/Download_Shortcode.php (modified) (1 diff)
-
tags/4.0.2/src/Helpers.php (modified) (3 diffs)
-
tags/4.0.2/src/Options.php (modified) (1 diff)
-
tags/4.0.2/src/Plugin.php (modified) (6 diffs)
-
tags/4.0.2/src/TinyMCE.php (modified) (1 diff)
-
tags/4.0.2/src/Upgrader.php (modified) (2 diffs)
-
tags/4.0.2/src/Widget.php (modified) (3 diffs)
-
trunk/admin/pages/_edit-link.php (modified) (4 diffs)
-
trunk/kama_click_counter.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (5 diffs)
-
trunk/src/Admin.php (modified) (11 diffs)
-
trunk/src/Content_Replacer.php (modified) (2 diffs)
-
trunk/src/Counter.php (modified) (8 diffs)
-
trunk/src/Download_Shortcode.php (modified) (1 diff)
-
trunk/src/Helpers.php (modified) (3 diffs)
-
trunk/src/Options.php (modified) (1 diff)
-
trunk/src/Plugin.php (modified) (6 diffs)
-
trunk/src/TinyMCE.php (modified) (1 diff)
-
trunk/src/Upgrader.php (modified) (2 diffs)
-
trunk/src/Widget.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kama-clic-counter/tags/4.0.2/admin/pages/_edit-link.php
r3056424 r3282892 1 1 <?php 2 3 2 namespace KamaClickCounter; 4 3 … … 7 6 /** 8 7 * @var Admin $this 8 * @var int $edit_link_id 9 9 */ 10 10 11 11 global $wpdb; 12 12 13 $link = $wpdb->get_row( "SELECT * FROM $wpdb->kcc_clicks WHERE link_id = " . (int) $edit_link_id);13 $link = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->kcc_clicks WHERE link_id = %d", $edit_link_id ) ); 14 14 15 15 if( ! $link ){ … … 46 46 <input type="hidden" name="local_referer" value="<?= esc_attr($referer) ?>" /> 47 47 48 <img style="position:absolute; top:-10px; right:350px; width:70px; width:50px;" src="<?= $icon_link ?>"/>48 <img style="position:absolute; top:-10px; right:350px; width:70px; height:50px;" src="<?= $icon_link ?>" alt=""/> 49 49 <p> 50 50 <input type="number" style="width:100px;" name="up[link_clicks]" value='<?= esc_attr( $link->link_clicks ) ?>' /> <?php printf( __('Clicks. Per day: %s', 'kama-clic-counter'), ($var=get_clicks_per_day($link)) ? $var : 0 ) ?></p> … … 62 62 </p> 63 63 <p> 64 <input type="text" style="width:600px;" name="up[link_url]" value="<?= esc_attr( $link->link_url ) ?>" readonly="readonly" /> <a href="#" style="margin-top:.5em; font-size:110%;" class="dashicons dashicons-edit" onclick="var $the = jQuery(this); $the.parent().find('input').removeAttr('readonly').focus(); $the.remove();"></a> <?php _e('Link to file', 'kama-clic-counter') ?> 64 <input type="text" style="width:600px;" name="up[link_url]" value="<?= esc_attr( $link->link_url ) ?>" readonly="readonly" /> 65 <a href="#" style="margin-top:.5em; font-size:110%;" class="dashicons dashicons-edit" 66 onclick="const $the = jQuery(this) $the.parent().find('input').removeAttr('readonly').focus(); $the.remove();" 67 ></a> 68 <?php _e('Link to file', 'kama-clic-counter') ?> 65 69 </p> 66 70 <p> -
kama-clic-counter/tags/4.0.2/kama_click_counter.php
r3167383 r3282892 2 2 /** 3 3 * Plugin Name: Kama Click Counter 4 * Description: Count clicks on any link all over the site. Creates beautiful file download block in post content - use shortcode [download url="any file URL"]. Has widget oftop clicks/downloads.4 * Description: Counts clicks on any link across the entire site. Creates a beautiful file download block in post content using the shortcode `[download url="any file URL"]`. Includes a widget for top clicks/downloads. 5 5 * 6 6 * Text Domain: kama-clic-counter … … 11 11 * Plugin URI: https://wp-kama.com/77 12 12 * 13 * Requires PHP: 7. 013 * Requires PHP: 7.1 14 14 * Requires at least: 5.7 15 15 * 16 * Version: 4.0. 116 * Version: 4.0.2 17 17 */ 18 18 … … 26 26 register_activation_hook( __FILE__, [ plugin(), 'activation' ] ); 27 27 28 add_action( 'plugins_loaded', [ plugin(), 'init' ] ); 28 /** 29 * NOTE: Init the plugin later on the 'after_setup_theme' hook to 30 * run current_user_can() later to avoid possible conflicts. 31 */ 32 add_action( 'after_setup_theme', [ plugin(), 'init' ] ); 29 33 30 34 function plugin(): Plugin { -
kama-clic-counter/tags/4.0.2/readme.txt
r3167383 r3282892 1 2 1 === Plugin Name === 3 2 Stable tag: trunk 4 Tested up to: 6. 6.23 Tested up to: 6.8.0 5 4 Contributors: Tkama 6 5 Tags: analytics, statistics, count clicks, counter … … 8 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 8 10 Count clicks on any link all over the site. Creates beautiful file download block in post content. Has top downloads' widget. 9 Count clicks on any link across the site. Creates a beautiful file download block in post content. Includes a widget for top downloads. 10 11 11 12 12 13 13 == Description == 14 14 15 Using this plugin you will have statistics on clicks on file download or any other link all overthe site.16 17 To insert file download block use `[download url="any file URL"]` shortcode.18 19 Plugin don't have any additional instruments to uploads files. All files uploaded using standard wordpress media uploader. To create download block URL are used.20 21 In additional, plugin has:22 23 * Button in visual editor to fast insertfile download block shortcode.24 * Customizable widget, that allows output a list of "Top Downloads" or "Top link Clicks".15 With this plugin, you can gather statistics on clicks for file downloads or any other link across the site. 16 17 To insert a file download block, use the `[download url="any file URL"]` shortcode. 18 19 The plugin does not include additional tools for uploading files. All files must be uploaded using the standard WordPress media uploader. The URLs are then used to create the download block. 20 21 Additionally, the plugin includes: 22 23 * A button in the visual editor for quickly inserting the file download block shortcode. 24 * A customizable widget that allows you to display a list of "Top Downloads" or "Top Link Clicks." 25 25 26 26 … … 28 28 == Frequently Asked Questions == 29 29 30 = How can I customize download block with CSS? =31 32 Just customize CSS styles in plugin options page. Also you can add css styles into 'style.css'file of your theme.30 = How can I customize the download block with CSS? = 31 32 You can customize CSS styles on the plugin options page. Alternatively, you can add CSS styles to the `style.css` file of your theme. 33 33 34 34 … … 39 39 2. Plugin settings page. 40 40 3. Single link edit page. 41 4. TinyM cevisual editor downloads button.41 4. TinyMCE visual editor downloads button. 42 42 43 43 … … 45 45 == Changelog == 46 46 47 = 4.0.2 = 48 - CHG: Min PHP version 7.0 >> 7.1. 49 - FIX: Plugin `init` moved to `after_setup_theme` hook to avoid some conflicts. 50 - IMP: minor improvements. 51 - UPD: Tested up to: WP 6.8.0 52 47 53 = 4.0.1 = 48 * FIX: Bug fix in "counter.js"script.54 * FIX: Bug in `counter.js` script. 49 55 50 56 = 4.0.0 = 51 * Requires PHP >= 7.0.52 * Backcompat removed.53 * Code refactored.54 * PHP class autoloader added.55 * PHP namespaces added.56 * Filter `kcc_admin_access` renamed to `kcc_manage_access`.57 * Filter `parce_kcc_url` renamed to `click_counter__parse_kcc_url`.58 * Filter `get_url_icon` renamed to `click_counter__get_icon_url`.57 * CHG: Requires PHP >= 7.0. 58 * DEL: Removed backcompat code. 59 * IMP: Code refactored. 60 * ADD: PHP class autoloader. 61 * ADD: PHP namespaces. 62 * CHG: Filter `kcc_admin_access` renamed to `kcc_manage_access`. 63 * CHG: Filter `parce_kcc_url` renamed to `click_counter__parse_kcc_url`. 64 * CHG: Filter `get_url_icon` renamed to `click_counter__get_icon_url`. 59 65 60 66 = 3.6.10 = 61 * Minor improvemets.67 * IMP: Minor improvements. 62 68 63 69 = 3.6.9 = 64 * A little performance improvements and no jQuery dependence for base count js.70 * IMP: Performance improvements; no jQuery dependency for base count JS. 65 71 66 72 = 3.6.8.2 = 67 * BUG: some bug in previous version.73 * FIX: Bug in previous version. 68 74 69 75 = 3.6.8.1 = 70 * BUG: previously, the Protocol for external links was removed (leaved //).71 * FIX: compatibility with PHP 7.476 * FIX: Protocol for external links issue (leaving `//`). 77 * FIX: Compatibility with PHP 7.4. 72 78 73 79 = 3.6.8 = 74 * BUG: wrong count of URL with query parameters. Code improved!75 * BUG:in widget loop.76 * FIX: other minor fixes.80 * FIX: Wrong URL count with query parameters. 81 * FIX: Bug in widget loop. 82 * FIX: Other minor fixes. 77 83 78 84 = 3.6.7.3 = 79 * FIX: wrong `<title>` parsing in some cases.85 * FIX: `<title>` parsing issue. 80 86 81 87 = 3.6.7 = 82 * FIX: bug with wrong counting when 'hide link under id' option is enadled. 83 * FIX: minor code fixes 84 88 * FIX: Wrong counting with "hide link under id" option enabled. 89 * FIX: Minor code fixes. 85 90 86 91 = 3.6.6 = 87 * FIX: access_roleoption not saved.88 * ADD: desc attrto shortcode.92 * FIX: `access_role` option not saved. 93 * ADD: `desc` attribute to shortcode. 89 94 90 95 = 3.6.5 = 91 * FIX: because of missing http protocol, filesize was parsed incorrect sometimes (not parsed).96 * FIX: Filesize parsing issue due to missing HTTP protocol. 92 97 93 98 = 3.6.4.2 = 94 * CHG: Download block HTML markup and css styles changed a little - nothing important...99 * CHG: Minor changes to download block HTML markup and CSS styles. 95 100 96 101 = 3.6.4 = 97 * ADD: urldecode for incoming URLs writing to DB. Thank to Mark Carson!98 * NEW: Exclude url counting filter. See options page.102 * ADD: `urldecode` for incoming URLs when saving to DB. Thanks to Mark Carson. 103 * NEW: Exclude URL counting filter added (see options page). 99 104 100 105 = 3.6.3 = 101 * FIX: esc_url for wp_redirect() to avoid spaces deletion. Thank to Mark Carson!106 * FIX: `esc_url()` for `wp_redirect()` to avoid spaces deletion. Thanks to Mark Carson. 102 107 103 108 = 3.6.2 = 104 * ADD: 'in_post' field on edit link admin page. It allow change ID of the post where link is...105 * ADD: sanitize data on edit link POST request106 * NEW: now all url in database saves as no protocol url - //site.ru/foo. So click on url 'http://site.ru/foo' and click on 'https://site.ru/foo' will be counted in one place.107 * FIX: search in admin list worked incorrectly if we begun search from pagination page...108 * FIX: correct detection of urls without protocol - //site.ru/foo109 * FIX: correct title detection of urls without protocol - //site.ru/foo. Now uses WP HTTP API to retrive external html of link...110 * FIX: some minor bug fixes109 * ADD: `in_post` field on edit link admin page to change associated post ID. 110 * ADD: Sanitize data on edit link POST request. 111 * NEW: Save URLs without protocol (`//site.ru/foo`). 112 * FIX: Admin list search starting from pagination page. 113 * FIX: Detection of URLs without protocol. 114 * FIX: Title detection for protocol-less URLs using WP HTTP API. 115 * FIX: Minor bug fixes. 111 116 112 117 = 3.6.1 = 113 * ADD: 'title' attribute to [download] shortcode. Ex: [download url="URL" title="my file title"] 114 * ADD: improve tinymce button insert shortcode modal window - now you can find files in media library. 115 * FIX: It just counted the clicks done with the left-click-mouse-button and not counted clicks with the mouse-wheel and not with "open link..." from context menu opened with right-mouse-click. 116 118 * ADD: `title` attribute for `[download]` shortcode. 119 * ADD: Improved TinyMCE button modal window (browse media library). 120 * FIX: Count clicks from mouse wheel and context menu. 117 121 118 122 = 3.6.0 = 119 * CHG: class name 'KCClick' changed to 'KCCounter'. If you have external code for this plugin, change in it all 'KCClick::' or 'KCC::' to 'KCCounter::'!!!120 * CHG: Icon in Tiny mce visual editor123 * CHG: Class name `KCClick` changed to `KCCounter`. 124 * CHG: Icon in TinyMCE visual editor updated. 121 125 122 126 = 3.5.1 = 123 * CHG: move localisation to translate.wordpress.org124 * FIX: minor code fix127 * CHG: Move localization to translate.wordpress.org. 128 * FIX: Minor code fix. 125 129 126 130 = 3.5.0 = 127 * FIX: XSS v alneruble128 * CHG: C hange class name 'KCC' to 'KCClick'129 * CHG: Translate PHP code to english. Now Russian is localization file...131 * FIX: XSS vulnerability fixed. 132 * CHG: Class name `KCC` changed to `KCClick`. 133 * CHG: Translate PHP code to English (Russian moved to localization file). 130 134 131 135 = 3.4.9 = 132 * FIX: Remove link from Admin-bar for Roles who has no plugin access136 * FIX: Remove admin-bar link for roles without plugin access. 133 137 134 138 = 3.4.8 = 135 * ADD: " click per day" data to edit link screen139 * ADD: "Clicks per day" data on edit link screen. 136 140 137 141 = 3.4.7 - 3.4.7.3 = 138 * FIX: table structure to work fine with 'utf8mb4_unicode_ci' charset142 * FIX: Table structure to support `utf8mb4_unicode_ci` charset. 139 143 140 144 = 3.4.6 = 141 * ADD: 'get_url_icon'filter to manage icons.145 * ADD: `get_url_icon` filter to manage icons. 142 146 143 147 = 3.4.5 = 144 * ADD: Administrator option to set access to pluginto other WP roles.145 * ADD: Option to add link to KCC Stat inadmin bar.146 * DEL: no HTTP_REFERER block on direct kcc urluse.148 * ADD: Administrator option to assign plugin access to other WP roles. 149 * ADD: Option to add KCC Stats link to admin bar. 150 * DEL: Removed `HTTP_REFERER` block on direct KCC URL use. 147 151 148 152 = 3.4.4 = 149 * CH ANGE: is_file extention check method for url.150 * ADD: 'kcc_is_file' filter151 * ADD: widget option to set link to post instead of link to file152 * REMOVED: 'kcc_file_ext' filter153 * CHG: `is_file` extension check method for URL. 154 * ADD: `kcc_is_file` filter. 155 * ADD: Widget option to set link to post instead of file. 156 * DEL: Removed `kcc_file_ext` filter. 153 157 154 158 = 3.4.3 = 155 * ADD hooks: 'parce_kcc_url', 'kcc_count_before', 'kcc_count_after'.156 * ADD: second parametr '$args' to 'kcc_insert_link_data'filter.157 * ADD: punycode support. Now links filter in admin table trying to find keyword in 'link_name' db column too, not only in 'link_url'.158 * FIX: It just count the clicks done with the left-click mouse button. Doesn't count clicks done with the mouse wheel, which opens in new tab. Also doesn't count clicks from mobile browsers. left click, mouse wheel, ctrl + left click, touch clicks (I test it in iphone – chrome and safari)159 * ADD: Hooks `parce_kcc_url`, `kcc_count_before`, `kcc_count_after`. 160 * ADD: Second parameter `$args` to `kcc_insert_link_data` filter. 161 * ADD: Punycode support for link filtering. 162 * FIX: Count clicks from mouse wheel, touch, and ctrl+click. 159 163 160 164 = 3.4.2 = 161 * ADD: 'kcc_admin_access' filter. For possibilityto change access capability.162 * FIX: redirect protection fix.165 * ADD: `kcc_admin_access` filter to change access capability. 166 * FIX: Redirect protection fix. 163 167 164 168 = 3.4.1 = 165 * FIX: parse kcc url fix.169 * FIX: KCC URL parsing issue. 166 170 167 171 = 3.4.0 = 168 * ADD: Hide url in download block option. See the options page. 169 * ADD: 'link_url' column index in DB for faster plugin work. 170 * ADD: 'get_kcc_url', 'kcc_redefine_redirect', 'kcc_file_ext', 'kcc_insert_link_data' hooks. 171 * ADD: Now plugin replace its ugly URL with original URL, when link hover. 172 * ADD: Replace 'edit link' text for download block to icon. It's more convenient. 173 * FIX: Correct updates of existing URLs. In some cases there appeared duplicates, when link contain '%' symbol (it could be cyrillic url or so on...) 174 * FIX: XSS attack protection. 175 * FIX: Many structure fix in code. 176 172 * ADD: Option to hide URL in download block. 173 * ADD: `link_url` column index in DB for performance. 174 * ADD: Hooks `get_kcc_url`, `kcc_redefine_redirect`, `kcc_file_ext`, `kcc_insert_link_data`. 175 * ADD: Replace ugly URL with original URL on hover. 176 * ADD: Replace "edit link" text in download block with icon. 177 * FIX: Duplicate URL updates (e.g., containing `%` symbol). 178 * FIX: XSS protection added. 179 * FIX: Code structure fixes. 177 180 178 181 = 3.3.2 = 179 * FIX: php notice182 * FIX: PHP notice. 180 183 181 184 = 3.3.1 = 182 * ADD: de_DE l10n, thanks to Volker Typke.185 * ADD: `de_DE` localization. Thanks to Volker Typke. 183 186 184 187 = 3.3.0 = 185 * ADD: l10n on plugin page.186 * ADD: menu to admin page.187 * FIX: antivirus wrongly says that file infected.188 * ADD: Localization on plugin page. 189 * ADD: Menu to admin page. 190 * FIX: Antivirus false positive detection. 188 191 189 192 = 3.2.34 = 190 * FIX: Some admin css change193 * FIX: Admin CSS changes. 191 194 192 195 = 3.2.3.3 = 193 * ADD: jQuery links become hidden. All jQuery affected links have #kcc anchor and onclick attr with countclick url194 * FIX: error with parse_url part. If url had "=" it was exploded...196 * ADD: jQuery links now hidden with `#kcc` anchor and `onclick` attribute. 197 * FIX: `parse_url` bug when URL contained "=" character. 195 198 196 199 = 3.2.3.2 = 197 * FIX: didn't correctly redirected to url with " " character198 * ADD: round "clicks per day" on admin statistics page to one decimal digit200 * FIX: Redirect to URL with space (`" "`) character. 201 * ADD: Round "clicks per day" value to one decimal on admin stats page. 199 202 200 203 = 3.2.3.1 = 201 * FIX: " back to stat" link on "edit link" admin page204 * FIX: "Back to stat" link on "edit link" admin page. 202 205 203 206 = 3.2.3 = 204 * FIX: redirects to https doesn't worked correctly205 * FIX: PHP less than 5.3 support206 * FIX: go back button on "edit link" admin page207 * FIX: localization207 * FIX: Redirects to HTTPS were not working correctly. 208 * FIX: PHP < 5.3 support. 209 * FIX: "Go back" button on "edit link" admin page. 210 * FIX: Localization issues. 208 211 209 212 = 3.2.2 = 210 * ADD: " go back" button on "edit link" admin page213 * ADD: "Go back" button on "edit link" admin page. 211 214 212 215 = 3.2.1 = 213 Set autoreplace old shortcodes to new in DB during update: [download=""] [download url=""] 216 * CHG: Auto-replace old shortcodes `[download=""]` with `[download url=""]` in DB during update. 214 217 215 218 = 3.2 = 216 Widget has been added 219 * ADD: Widget feature. 220 -
kama-clic-counter/tags/4.0.2/src/Admin.php
r3056424 r3282892 33 33 } 34 34 35 public function upgrade() {35 public function upgrade() { 36 36 $upgrader = new Upgrader(); 37 37 $upgrader->init(); … … 42 42 * For WP hook. 43 43 */ 44 public function plugins_page_links( $actions ) {44 public function plugins_page_links( $actions ) { 45 45 46 46 $actions[] = sprintf( '<a href="%s">%s</a>', $this->admin_page_url( 'settings' ), __( 'Settings', 'kama-clic-counter' ) ); … … 50 50 } 51 51 52 public function admin_menu() {52 public function admin_menu() { 53 53 54 54 // just in case … … 69 69 } 70 70 71 public function admin_page_load() {71 public function admin_page_load() { 72 72 73 73 // just in case... … … 96 96 is_string( $val ) && $val = trim( $val ); 97 97 98 if( $key === 'download_tpl' ){} // no sanitize... wp_kses($val, 'post'); 99 elseif( $key === 'url_exclude_patterns' ){} // no sanitize... 98 if( $key === 'download_tpl' ){ 99 // no sanitize... 100 } 101 elseif( $key === 'url_exclude_patterns' ){ 102 // no sanitize... wp_kses($val, 'post'); 103 } 104 // no sanitize... 100 105 elseif( is_array( $val ) ){ 101 106 $val = array_map( 'sanitize_key', $val ); … … 136 141 137 142 $data = wp_unslash( $_POST['up'] ); 138 $id = (int) $data['link_id'];143 $id = (int) $data['link_id']; 139 144 140 145 // очистка … … 210 215 * Callback for {@see add_options_page()} function parameter. 211 216 */ 212 public function options_page_output() {217 public function options_page_output() { 213 218 include plugin()->dir . '/admin/pages/admin.php'; 214 219 } 215 220 216 221 /** 217 * @param int $link_id218 * @param array $data219 *220 222 * @return int|false 221 223 */ 222 private function update_link( $link_id, $data ) { 223 global $wpdb; 224 225 $link_id = (int) $link_id; 224 private function update_link( int $link_id, array $data ) { 225 global $wpdb; 226 226 227 if( $link_id ){ 227 228 $query = $wpdb->update( $wpdb->kcc_clicks, $data, [ 'link_id' => $link_id ] ); … … 243 244 244 245 public function delete_link_url( $link_id ): string { 245 return add_query_arg( [ 'delete_link' => $link_id, '_wpnonce' => wp_create_nonce('delete_link') ] );246 return add_query_arg( [ 'delete_link' => $link_id, '_wpnonce' => wp_create_nonce( 'delete_link' ) ] ); 246 247 } 247 248 … … 249 250 * Deleting links from the database by passed array ID or link ID. 250 251 * 251 * @param array|int $array_idsIDs of links to be deleted.252 * @param array|int $array_ids IDs of links to be deleted. 252 253 */ 253 254 private function delete_links( $array_ids = [] ): bool { … … 263 264 } 264 265 265 public function delete_link_by_attach_id( $attach_id ) {266 public function delete_link_by_attach_id( $attach_id ) { 266 267 global $wpdb; 267 268 … … 276 277 * Update the link if the attachment is updated. 277 278 */ 278 public function update_link_with_attach( $attach_id ) {279 public function update_link_with_attach( $attach_id ) { 279 280 global $wpdb; 280 281 -
kama-clic-counter/tags/4.0.2/src/Content_Replacer.php
r3056424 r3282892 5 5 class Content_Replacer { 6 6 7 public function __construct() {7 public function __construct() { 8 8 } 9 9 10 public function init() {10 public function init() { 11 11 12 12 if( plugin()->opt->links_class ){ … … 45 45 foreach( $args[0] as $pair ){ 46 46 list( $tag, $value ) = explode( '=', $pair, 2 ); 47 $value = trim( trim( $value, '"\'') );48 $args[ trim( $tag) ] = $value;47 $value = trim( trim( $value, '"\'' ) ); 48 $args[ trim( $tag ) ] = $value; 49 49 } 50 50 unset( $args[0], $args[1] ); 51 51 52 52 $after = ''; 53 $args[ 'data-' . Counter::PID_KEY ] = $post->ID;53 $args[ 'data-' . Counter::PID_KEY ] = $post->ID; 54 54 if( plugin()->opt->add_hits ){ 55 55 $link = plugin()->counter->get_link( $args['href'] ); -
kama-clic-counter/tags/4.0.2/src/Counter.php
r3167383 r3282892 17 17 public $opt; 18 18 19 public function __construct( Options $options ) {19 public function __construct( Options $options ) { 20 20 21 21 $this->opt = $options; … … 95 95 * Hides the original link under the link ID. The link must exist in the database. 96 96 * 97 * @param string $kcc_url Plugin formated URL of the link counting.97 * @param string $kcc_url Plugin formated URL of the link counting. 98 98 * 99 99 * @return string URL with a hidden link. … … 368 368 else{ 369 369 trigger_error( sprintf( 'Error: kcc link with id %s not found.', $url ) ); 370 370 371 return; 371 372 } … … 399 400 400 401 // cut URL from $query, because - there could be query args (&) that is why cut it 401 $split = preg_split( '/[&?]?' . self::COUNT_KEY .'=/', $kcc_query );402 $split = preg_split( '/[&?]?' . self::COUNT_KEY . '=/', $kcc_query ); 402 403 $query = $split[0]; 403 $url = self::replace_url_placeholders( $split[1] ); // can be base64 encoded404 $url = self::replace_url_placeholders( $split[1] ); // can be base64 encoded 404 405 405 406 if( ! $url ){ … … 427 428 ! is_numeric( $url ) 428 429 && $url[0] !== '/' 429 && ! preg_match( '~^( ?:' . implode( '|', wp_allowed_protocols() ) . '):~', $url )430 ) {430 && ! preg_match( '~^(' . implode( '|', wp_allowed_protocols() ) . '):~', $url ) 431 ){ 431 432 return []; 432 433 } 433 434 434 435 $return = [ 435 self::COUNT_KEY => $url, // no esc_url()436 self::COUNT_KEY => $url, // !!! no esc_url() 436 437 self::PID_KEY => (int) ( $query_args[ self::PID_KEY ] ?? 0 ), 437 438 // array_key_exists( 'download', $query_args ), // isset null не берет … … 442 443 } 443 444 444 public static function del_http_protocol( $url ) {445 public static function del_http_protocol( $url ) { 445 446 return preg_replace( '/https?:/', '', $url ); 446 447 } 447 448 448 private function is_file( $url ) {449 private function is_file( $url ) { 449 450 /** 450 451 * Allows to repalce {@see Counter::is_file()} method. … … 537 538 $i = 0; 538 539 $type = [ "B", "KB", "MB", "GB" ]; 539 while( ( $size /1024 ) > 1 ){540 $size = $size /1024;540 while( ( $size / 1024 ) > 1 ){ 541 $size = $size / 1024; 541 542 $i++; 542 543 } … … 548 549 * Returns the size of a file without downloading it. 549 550 * 550 * @param string $url The location of the remote file to download. Cannot be null or empty.551 * @param string $url The location of the remote file to download. Cannot be null or empty. 551 552 * 552 553 * @return int The size of the file referenced by $url, or 0 if the size could not be determined. -
kama-clic-counter/tags/4.0.2/src/Download_Shortcode.php
r3056424 r3282892 5 5 class Download_Shortcode { 6 6 7 public function __construct() {7 public function __construct() { 8 8 } 9 9 10 public function init() {10 public function init() { 11 11 add_shortcode( 'download', [ $this, 'download_shortcode' ] ); 12 12 } -
kama-clic-counter/tags/4.0.2/src/Helpers.php
r3056424 r3282892 6 6 7 7 /** 8 * @param string $message MessageHTML.9 * @param string $type Allowed: success | error | warning |info.8 * @param string $message HTML. 9 * @param string $type One of: success|error|warning|info. 10 10 */ 11 11 public static function notice_message( string $message, string $type = 'warning' ) { 12 12 13 add_action( 14 'admin_notices', 15 function () use ( $message, $type ) { 16 ?> 17 <div id="message" class="notice <?= esc_attr( "notice-$type" ) ?>"> 18 <p><?= wp_kses_post( $message ) ?></p> 19 </div> 20 <?php 21 } 22 ); 13 add_action( 'admin_notices', function() use ( $message, $type ) { 14 ?> 15 <div id="message" class="notice <?= esc_attr( "notice-$type" ) ?>"> 16 <p><?= wp_kses_post( $message ) ?></p> 17 </div> 18 <?php 19 } ); 23 20 } 24 21 … … 26 23 * Gets a link to the icon image by the extension in the passed URL. 27 24 * 28 * @param $link_url29 *30 25 * @return mixed|null 31 26 */ 32 public static function get_icon_url( $link_url ) {27 public static function get_icon_url( $link_url ) { 33 28 34 29 $url_path = parse_url( $link_url, PHP_URL_PATH ); … … 37 32 $icon_name = $m[1] . '.png'; 38 33 } 39 else {34 else { 40 35 $icon_name = 'default.png'; 41 36 } -
kama-clic-counter/tags/4.0.2/src/Options.php
r3056424 r3282892 49 49 ', 50 50 // css class for links in content (if not specified, this functionality is disabled). 51 'links_class' => 'count',51 'links_class' => 'count', 52 52 // may be: '', 'in_title' or 'in_plain' (for simple links) 53 53 'add_hits' => '', -
kama-clic-counter/tags/4.0.2/src/Plugin.php
r3056424 r3282892 42 42 43 43 public function __construct( string $main_file_path ) { 44 45 44 $this->set_wpdb_tables(); 46 45 … … 50 49 $this->url = plugins_url( '', $main_file_path ); 51 50 52 $this->info = get_file_data( 53 $main_file_path, 54 [ 55 'name' => 'Plugin Name', 56 'version' => 'Version', 57 'php_ver' => 'Requires PHP', 58 ] 59 ); 51 $this->info = get_file_data( $main_file_path, [ 52 'name' => 'Plugin Name', 53 'version' => 'Version', 54 'php_ver' => 'Requires PHP', 55 ] ); 60 56 61 57 $this->opt = new Options(); 62 58 } 63 59 64 /** 65 * The plugin initialization. Performs on `plugins_loaded` hook. 66 * 67 * @return void 68 */ 69 public function init() { 60 public function init(): void { 70 61 71 if ( ! $this->check_dependencies() ){62 if( ! $this->check_dependencies() ){ 72 63 return; 73 64 } … … 107 98 } 108 99 109 /** 110 * @return void 111 */ 112 private function set_admin_access() { 100 private function set_admin_access(): void { 113 101 $this->admin_access = current_user_can( 'manage_options' ); 114 102 } 115 103 116 /** 117 * @return void 118 */ 119 private function set_manage_access() { 104 private function set_manage_access(): void { 120 105 121 106 $this->manage_access = apply_filters( 'kcc_manage_access', null ); … … 139 124 } 140 125 141 public function add_toolbar_menu( $toolbar ) {126 public function add_toolbar_menu( $toolbar ) { 142 127 143 128 $toolbar->add_menu( [ … … 149 134 150 135 public function check_dependencies(): bool { 151 152 if ( version_compare( PHP_VERSION, $this->info['php_ver'], '<=' ) ) { 153 136 if( version_compare( PHP_VERSION, $this->info['php_ver'], '<=' ) ){ 154 137 Helpers::notice_message( 155 138 '<b>Kama Click Counter</b> plugin requires PHP version <b>' . $this->info['php_ver'] . '</b> or higher. Please upgrade PHP or diactivate the plugin.', … … 163 146 } 164 147 165 public function activation() {148 public function activation() { 166 149 global $wpdb; 167 150 168 if ( ! $this->check_dependencies() ){151 if( ! $this->check_dependencies() ){ 169 152 return; 170 153 } -
kama-clic-counter/tags/4.0.2/src/TinyMCE.php
r3056424 r3282892 21 21 22 22 public static function register_buttons( $buttons ) { 23 $last = array_pop( $buttons );23 $last = array_pop( $buttons ); 24 24 $buttons[] = 'kcc'; 25 25 $buttons[] = $last; -
kama-clic-counter/tags/4.0.2/src/Upgrader.php
r3056424 r3282892 22 22 private $db_fields; 23 23 24 public function __construct() {25 $this->is_force_upgrade = isset( $_GET['kcc_force_upgrade'] );24 public function __construct() { 25 $this->is_force_upgrade = isset( $_GET['kcc_force_upgrade'] ); 26 26 27 $this->prev_ver = $this->is_force_upgrade ? '1.0' : get_option( self::OPTION_NAME, '1.0' );28 $this->curr_ver = plugin()->info['version'];27 $this->prev_ver = $this->is_force_upgrade ? '1.0' : get_option( self::OPTION_NAME, '1.0' ); 28 $this->curr_ver = plugin()->info['version']; 29 29 } 30 30 … … 50 50 exit; 51 51 } 52 53 52 } 54 53 -
kama-clic-counter/tags/4.0.2/src/Widget.php
r3056424 r3282892 13 13 } 14 14 15 public static function init() {15 public static function init() { 16 16 17 17 if( ! plugin()->opt->widget ){ … … 19 19 } 20 20 21 add_action( 'widgets_init', function () {21 add_action( 'widgets_init', function() { 22 22 register_widget( self::class ); 23 23 } ); … … 125 125 * Admin part of the widget 126 126 */ 127 public function form( $instance ){ 128 129 $title = @ $instance['title'] ? $instance[ 'title' ] : __('Top Downloads', 'kama-clic-counter' ); 130 $number = @ $instance['number'] ? $instance[ 'number' ] : 5; 131 $last_date = @ $instance['last_date'] ? $instance[ 'last_date' ] : ''; 132 $template_css = @ $instance['template_css'] 133 ? $instance[ 'template_css' ] 134 : preg_replace( 135 '~^\t+~m', '', '.kcc_widget{ padding:15px; } 136 .kcc_widget li{ margin-bottom:10px; list-style: none; } 137 .kcc_widget li:after{ content:""; display:table; clear:both; } 138 .kcc_widget img{ width:30px; float:left; margin:5px 10px 5px 0; } 139 .kcc_widget p{ margin-left:40px; }' 140 ); 141 142 $template = @ $instance['template'] 143 ? $instance['template'] 144 : '<img src="[icon_url]" alt="" />' . "\n" 145 . '<a href="[link_url]">[link_title]</a> ([link_clicks])' . "\n" 146 . '<p>[link_description]</p>'; 127 public function form( $instance ) { 128 129 $default_template_css = ' 130 .kcc_widget{ padding:15px; } 131 .kcc_widget li{ margin-bottom:10px; list-style: none; } 132 .kcc_widget li:after{ content:""; display:table; clear:both; } 133 .kcc_widget img{ width:30px; float:left; margin:5px 10px 5px 0; } 134 .kcc_widget p{ margin-left:40px; } 135 '; 136 137 $default_template = ' 138 <img src="[icon_url]" alt="" /> 139 <a href="[link_url]">[link_title]</a> ([link_clicks]) 140 <p>[link_description]</p> 141 '; 142 143 $title = $instance['title'] ?? __( 'Top Downloads', 'kama-clic-counter' ); 144 $number = $instance['number'] ?? 5; 145 $last_date = $instance['last_date'] ?? ''; 146 $template_css = $instance['template_css'] ?? preg_replace( '~^\t+~m', '', trim( $default_template_css ) ); 147 $template = $instance['template'] ?? preg_replace( '~^\t+~m', '', trim( $default_template ) ); 147 148 ?> 148 149 <p> -
kama-clic-counter/trunk/admin/pages/_edit-link.php
r3056424 r3282892 1 1 <?php 2 3 2 namespace KamaClickCounter; 4 3 … … 7 6 /** 8 7 * @var Admin $this 8 * @var int $edit_link_id 9 9 */ 10 10 11 11 global $wpdb; 12 12 13 $link = $wpdb->get_row( "SELECT * FROM $wpdb->kcc_clicks WHERE link_id = " . (int) $edit_link_id);13 $link = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->kcc_clicks WHERE link_id = %d", $edit_link_id ) ); 14 14 15 15 if( ! $link ){ … … 46 46 <input type="hidden" name="local_referer" value="<?= esc_attr($referer) ?>" /> 47 47 48 <img style="position:absolute; top:-10px; right:350px; width:70px; width:50px;" src="<?= $icon_link ?>"/>48 <img style="position:absolute; top:-10px; right:350px; width:70px; height:50px;" src="<?= $icon_link ?>" alt=""/> 49 49 <p> 50 50 <input type="number" style="width:100px;" name="up[link_clicks]" value='<?= esc_attr( $link->link_clicks ) ?>' /> <?php printf( __('Clicks. Per day: %s', 'kama-clic-counter'), ($var=get_clicks_per_day($link)) ? $var : 0 ) ?></p> … … 62 62 </p> 63 63 <p> 64 <input type="text" style="width:600px;" name="up[link_url]" value="<?= esc_attr( $link->link_url ) ?>" readonly="readonly" /> <a href="#" style="margin-top:.5em; font-size:110%;" class="dashicons dashicons-edit" onclick="var $the = jQuery(this); $the.parent().find('input').removeAttr('readonly').focus(); $the.remove();"></a> <?php _e('Link to file', 'kama-clic-counter') ?> 64 <input type="text" style="width:600px;" name="up[link_url]" value="<?= esc_attr( $link->link_url ) ?>" readonly="readonly" /> 65 <a href="#" style="margin-top:.5em; font-size:110%;" class="dashicons dashicons-edit" 66 onclick="const $the = jQuery(this) $the.parent().find('input').removeAttr('readonly').focus(); $the.remove();" 67 ></a> 68 <?php _e('Link to file', 'kama-clic-counter') ?> 65 69 </p> 66 70 <p> -
kama-clic-counter/trunk/kama_click_counter.php
r3167383 r3282892 2 2 /** 3 3 * Plugin Name: Kama Click Counter 4 * Description: Count clicks on any link all over the site. Creates beautiful file download block in post content - use shortcode [download url="any file URL"]. Has widget oftop clicks/downloads.4 * Description: Counts clicks on any link across the entire site. Creates a beautiful file download block in post content using the shortcode `[download url="any file URL"]`. Includes a widget for top clicks/downloads. 5 5 * 6 6 * Text Domain: kama-clic-counter … … 11 11 * Plugin URI: https://wp-kama.com/77 12 12 * 13 * Requires PHP: 7. 013 * Requires PHP: 7.1 14 14 * Requires at least: 5.7 15 15 * 16 * Version: 4.0. 116 * Version: 4.0.2 17 17 */ 18 18 … … 26 26 register_activation_hook( __FILE__, [ plugin(), 'activation' ] ); 27 27 28 add_action( 'plugins_loaded', [ plugin(), 'init' ] ); 28 /** 29 * NOTE: Init the plugin later on the 'after_setup_theme' hook to 30 * run current_user_can() later to avoid possible conflicts. 31 */ 32 add_action( 'after_setup_theme', [ plugin(), 'init' ] ); 29 33 30 34 function plugin(): Plugin { -
kama-clic-counter/trunk/readme.txt
r3167383 r3282892 1 2 1 === Plugin Name === 3 2 Stable tag: trunk 4 Tested up to: 6. 6.23 Tested up to: 6.8.0 5 4 Contributors: Tkama 6 5 Tags: analytics, statistics, count clicks, counter … … 8 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 8 10 Count clicks on any link all over the site. Creates beautiful file download block in post content. Has top downloads' widget. 9 Count clicks on any link across the site. Creates a beautiful file download block in post content. Includes a widget for top downloads. 10 11 11 12 12 13 13 == Description == 14 14 15 Using this plugin you will have statistics on clicks on file download or any other link all overthe site.16 17 To insert file download block use `[download url="any file URL"]` shortcode.18 19 Plugin don't have any additional instruments to uploads files. All files uploaded using standard wordpress media uploader. To create download block URL are used.20 21 In additional, plugin has:22 23 * Button in visual editor to fast insertfile download block shortcode.24 * Customizable widget, that allows output a list of "Top Downloads" or "Top link Clicks".15 With this plugin, you can gather statistics on clicks for file downloads or any other link across the site. 16 17 To insert a file download block, use the `[download url="any file URL"]` shortcode. 18 19 The plugin does not include additional tools for uploading files. All files must be uploaded using the standard WordPress media uploader. The URLs are then used to create the download block. 20 21 Additionally, the plugin includes: 22 23 * A button in the visual editor for quickly inserting the file download block shortcode. 24 * A customizable widget that allows you to display a list of "Top Downloads" or "Top Link Clicks." 25 25 26 26 … … 28 28 == Frequently Asked Questions == 29 29 30 = How can I customize download block with CSS? =31 32 Just customize CSS styles in plugin options page. Also you can add css styles into 'style.css'file of your theme.30 = How can I customize the download block with CSS? = 31 32 You can customize CSS styles on the plugin options page. Alternatively, you can add CSS styles to the `style.css` file of your theme. 33 33 34 34 … … 39 39 2. Plugin settings page. 40 40 3. Single link edit page. 41 4. TinyM cevisual editor downloads button.41 4. TinyMCE visual editor downloads button. 42 42 43 43 … … 45 45 == Changelog == 46 46 47 = 4.0.2 = 48 - CHG: Min PHP version 7.0 >> 7.1. 49 - FIX: Plugin `init` moved to `after_setup_theme` hook to avoid some conflicts. 50 - IMP: minor improvements. 51 - UPD: Tested up to: WP 6.8.0 52 47 53 = 4.0.1 = 48 * FIX: Bug fix in "counter.js"script.54 * FIX: Bug in `counter.js` script. 49 55 50 56 = 4.0.0 = 51 * Requires PHP >= 7.0.52 * Backcompat removed.53 * Code refactored.54 * PHP class autoloader added.55 * PHP namespaces added.56 * Filter `kcc_admin_access` renamed to `kcc_manage_access`.57 * Filter `parce_kcc_url` renamed to `click_counter__parse_kcc_url`.58 * Filter `get_url_icon` renamed to `click_counter__get_icon_url`.57 * CHG: Requires PHP >= 7.0. 58 * DEL: Removed backcompat code. 59 * IMP: Code refactored. 60 * ADD: PHP class autoloader. 61 * ADD: PHP namespaces. 62 * CHG: Filter `kcc_admin_access` renamed to `kcc_manage_access`. 63 * CHG: Filter `parce_kcc_url` renamed to `click_counter__parse_kcc_url`. 64 * CHG: Filter `get_url_icon` renamed to `click_counter__get_icon_url`. 59 65 60 66 = 3.6.10 = 61 * Minor improvemets.67 * IMP: Minor improvements. 62 68 63 69 = 3.6.9 = 64 * A little performance improvements and no jQuery dependence for base count js.70 * IMP: Performance improvements; no jQuery dependency for base count JS. 65 71 66 72 = 3.6.8.2 = 67 * BUG: some bug in previous version.73 * FIX: Bug in previous version. 68 74 69 75 = 3.6.8.1 = 70 * BUG: previously, the Protocol for external links was removed (leaved //).71 * FIX: compatibility with PHP 7.476 * FIX: Protocol for external links issue (leaving `//`). 77 * FIX: Compatibility with PHP 7.4. 72 78 73 79 = 3.6.8 = 74 * BUG: wrong count of URL with query parameters. Code improved!75 * BUG:in widget loop.76 * FIX: other minor fixes.80 * FIX: Wrong URL count with query parameters. 81 * FIX: Bug in widget loop. 82 * FIX: Other minor fixes. 77 83 78 84 = 3.6.7.3 = 79 * FIX: wrong `<title>` parsing in some cases.85 * FIX: `<title>` parsing issue. 80 86 81 87 = 3.6.7 = 82 * FIX: bug with wrong counting when 'hide link under id' option is enadled. 83 * FIX: minor code fixes 84 88 * FIX: Wrong counting with "hide link under id" option enabled. 89 * FIX: Minor code fixes. 85 90 86 91 = 3.6.6 = 87 * FIX: access_roleoption not saved.88 * ADD: desc attrto shortcode.92 * FIX: `access_role` option not saved. 93 * ADD: `desc` attribute to shortcode. 89 94 90 95 = 3.6.5 = 91 * FIX: because of missing http protocol, filesize was parsed incorrect sometimes (not parsed).96 * FIX: Filesize parsing issue due to missing HTTP protocol. 92 97 93 98 = 3.6.4.2 = 94 * CHG: Download block HTML markup and css styles changed a little - nothing important...99 * CHG: Minor changes to download block HTML markup and CSS styles. 95 100 96 101 = 3.6.4 = 97 * ADD: urldecode for incoming URLs writing to DB. Thank to Mark Carson!98 * NEW: Exclude url counting filter. See options page.102 * ADD: `urldecode` for incoming URLs when saving to DB. Thanks to Mark Carson. 103 * NEW: Exclude URL counting filter added (see options page). 99 104 100 105 = 3.6.3 = 101 * FIX: esc_url for wp_redirect() to avoid spaces deletion. Thank to Mark Carson!106 * FIX: `esc_url()` for `wp_redirect()` to avoid spaces deletion. Thanks to Mark Carson. 102 107 103 108 = 3.6.2 = 104 * ADD: 'in_post' field on edit link admin page. It allow change ID of the post where link is...105 * ADD: sanitize data on edit link POST request106 * NEW: now all url in database saves as no protocol url - //site.ru/foo. So click on url 'http://site.ru/foo' and click on 'https://site.ru/foo' will be counted in one place.107 * FIX: search in admin list worked incorrectly if we begun search from pagination page...108 * FIX: correct detection of urls without protocol - //site.ru/foo109 * FIX: correct title detection of urls without protocol - //site.ru/foo. Now uses WP HTTP API to retrive external html of link...110 * FIX: some minor bug fixes109 * ADD: `in_post` field on edit link admin page to change associated post ID. 110 * ADD: Sanitize data on edit link POST request. 111 * NEW: Save URLs without protocol (`//site.ru/foo`). 112 * FIX: Admin list search starting from pagination page. 113 * FIX: Detection of URLs without protocol. 114 * FIX: Title detection for protocol-less URLs using WP HTTP API. 115 * FIX: Minor bug fixes. 111 116 112 117 = 3.6.1 = 113 * ADD: 'title' attribute to [download] shortcode. Ex: [download url="URL" title="my file title"] 114 * ADD: improve tinymce button insert shortcode modal window - now you can find files in media library. 115 * FIX: It just counted the clicks done with the left-click-mouse-button and not counted clicks with the mouse-wheel and not with "open link..." from context menu opened with right-mouse-click. 116 118 * ADD: `title` attribute for `[download]` shortcode. 119 * ADD: Improved TinyMCE button modal window (browse media library). 120 * FIX: Count clicks from mouse wheel and context menu. 117 121 118 122 = 3.6.0 = 119 * CHG: class name 'KCClick' changed to 'KCCounter'. If you have external code for this plugin, change in it all 'KCClick::' or 'KCC::' to 'KCCounter::'!!!120 * CHG: Icon in Tiny mce visual editor123 * CHG: Class name `KCClick` changed to `KCCounter`. 124 * CHG: Icon in TinyMCE visual editor updated. 121 125 122 126 = 3.5.1 = 123 * CHG: move localisation to translate.wordpress.org124 * FIX: minor code fix127 * CHG: Move localization to translate.wordpress.org. 128 * FIX: Minor code fix. 125 129 126 130 = 3.5.0 = 127 * FIX: XSS v alneruble128 * CHG: C hange class name 'KCC' to 'KCClick'129 * CHG: Translate PHP code to english. Now Russian is localization file...131 * FIX: XSS vulnerability fixed. 132 * CHG: Class name `KCC` changed to `KCClick`. 133 * CHG: Translate PHP code to English (Russian moved to localization file). 130 134 131 135 = 3.4.9 = 132 * FIX: Remove link from Admin-bar for Roles who has no plugin access136 * FIX: Remove admin-bar link for roles without plugin access. 133 137 134 138 = 3.4.8 = 135 * ADD: " click per day" data to edit link screen139 * ADD: "Clicks per day" data on edit link screen. 136 140 137 141 = 3.4.7 - 3.4.7.3 = 138 * FIX: table structure to work fine with 'utf8mb4_unicode_ci' charset142 * FIX: Table structure to support `utf8mb4_unicode_ci` charset. 139 143 140 144 = 3.4.6 = 141 * ADD: 'get_url_icon'filter to manage icons.145 * ADD: `get_url_icon` filter to manage icons. 142 146 143 147 = 3.4.5 = 144 * ADD: Administrator option to set access to pluginto other WP roles.145 * ADD: Option to add link to KCC Stat inadmin bar.146 * DEL: no HTTP_REFERER block on direct kcc urluse.148 * ADD: Administrator option to assign plugin access to other WP roles. 149 * ADD: Option to add KCC Stats link to admin bar. 150 * DEL: Removed `HTTP_REFERER` block on direct KCC URL use. 147 151 148 152 = 3.4.4 = 149 * CH ANGE: is_file extention check method for url.150 * ADD: 'kcc_is_file' filter151 * ADD: widget option to set link to post instead of link to file152 * REMOVED: 'kcc_file_ext' filter153 * CHG: `is_file` extension check method for URL. 154 * ADD: `kcc_is_file` filter. 155 * ADD: Widget option to set link to post instead of file. 156 * DEL: Removed `kcc_file_ext` filter. 153 157 154 158 = 3.4.3 = 155 * ADD hooks: 'parce_kcc_url', 'kcc_count_before', 'kcc_count_after'.156 * ADD: second parametr '$args' to 'kcc_insert_link_data'filter.157 * ADD: punycode support. Now links filter in admin table trying to find keyword in 'link_name' db column too, not only in 'link_url'.158 * FIX: It just count the clicks done with the left-click mouse button. Doesn't count clicks done with the mouse wheel, which opens in new tab. Also doesn't count clicks from mobile browsers. left click, mouse wheel, ctrl + left click, touch clicks (I test it in iphone – chrome and safari)159 * ADD: Hooks `parce_kcc_url`, `kcc_count_before`, `kcc_count_after`. 160 * ADD: Second parameter `$args` to `kcc_insert_link_data` filter. 161 * ADD: Punycode support for link filtering. 162 * FIX: Count clicks from mouse wheel, touch, and ctrl+click. 159 163 160 164 = 3.4.2 = 161 * ADD: 'kcc_admin_access' filter. For possibilityto change access capability.162 * FIX: redirect protection fix.165 * ADD: `kcc_admin_access` filter to change access capability. 166 * FIX: Redirect protection fix. 163 167 164 168 = 3.4.1 = 165 * FIX: parse kcc url fix.169 * FIX: KCC URL parsing issue. 166 170 167 171 = 3.4.0 = 168 * ADD: Hide url in download block option. See the options page. 169 * ADD: 'link_url' column index in DB for faster plugin work. 170 * ADD: 'get_kcc_url', 'kcc_redefine_redirect', 'kcc_file_ext', 'kcc_insert_link_data' hooks. 171 * ADD: Now plugin replace its ugly URL with original URL, when link hover. 172 * ADD: Replace 'edit link' text for download block to icon. It's more convenient. 173 * FIX: Correct updates of existing URLs. In some cases there appeared duplicates, when link contain '%' symbol (it could be cyrillic url or so on...) 174 * FIX: XSS attack protection. 175 * FIX: Many structure fix in code. 176 172 * ADD: Option to hide URL in download block. 173 * ADD: `link_url` column index in DB for performance. 174 * ADD: Hooks `get_kcc_url`, `kcc_redefine_redirect`, `kcc_file_ext`, `kcc_insert_link_data`. 175 * ADD: Replace ugly URL with original URL on hover. 176 * ADD: Replace "edit link" text in download block with icon. 177 * FIX: Duplicate URL updates (e.g., containing `%` symbol). 178 * FIX: XSS protection added. 179 * FIX: Code structure fixes. 177 180 178 181 = 3.3.2 = 179 * FIX: php notice182 * FIX: PHP notice. 180 183 181 184 = 3.3.1 = 182 * ADD: de_DE l10n, thanks to Volker Typke.185 * ADD: `de_DE` localization. Thanks to Volker Typke. 183 186 184 187 = 3.3.0 = 185 * ADD: l10n on plugin page.186 * ADD: menu to admin page.187 * FIX: antivirus wrongly says that file infected.188 * ADD: Localization on plugin page. 189 * ADD: Menu to admin page. 190 * FIX: Antivirus false positive detection. 188 191 189 192 = 3.2.34 = 190 * FIX: Some admin css change193 * FIX: Admin CSS changes. 191 194 192 195 = 3.2.3.3 = 193 * ADD: jQuery links become hidden. All jQuery affected links have #kcc anchor and onclick attr with countclick url194 * FIX: error with parse_url part. If url had "=" it was exploded...196 * ADD: jQuery links now hidden with `#kcc` anchor and `onclick` attribute. 197 * FIX: `parse_url` bug when URL contained "=" character. 195 198 196 199 = 3.2.3.2 = 197 * FIX: didn't correctly redirected to url with " " character198 * ADD: round "clicks per day" on admin statistics page to one decimal digit200 * FIX: Redirect to URL with space (`" "`) character. 201 * ADD: Round "clicks per day" value to one decimal on admin stats page. 199 202 200 203 = 3.2.3.1 = 201 * FIX: " back to stat" link on "edit link" admin page204 * FIX: "Back to stat" link on "edit link" admin page. 202 205 203 206 = 3.2.3 = 204 * FIX: redirects to https doesn't worked correctly205 * FIX: PHP less than 5.3 support206 * FIX: go back button on "edit link" admin page207 * FIX: localization207 * FIX: Redirects to HTTPS were not working correctly. 208 * FIX: PHP < 5.3 support. 209 * FIX: "Go back" button on "edit link" admin page. 210 * FIX: Localization issues. 208 211 209 212 = 3.2.2 = 210 * ADD: " go back" button on "edit link" admin page213 * ADD: "Go back" button on "edit link" admin page. 211 214 212 215 = 3.2.1 = 213 Set autoreplace old shortcodes to new in DB during update: [download=""] [download url=""] 216 * CHG: Auto-replace old shortcodes `[download=""]` with `[download url=""]` in DB during update. 214 217 215 218 = 3.2 = 216 Widget has been added 219 * ADD: Widget feature. 220 -
kama-clic-counter/trunk/src/Admin.php
r3056424 r3282892 33 33 } 34 34 35 public function upgrade() {35 public function upgrade() { 36 36 $upgrader = new Upgrader(); 37 37 $upgrader->init(); … … 42 42 * For WP hook. 43 43 */ 44 public function plugins_page_links( $actions ) {44 public function plugins_page_links( $actions ) { 45 45 46 46 $actions[] = sprintf( '<a href="%s">%s</a>', $this->admin_page_url( 'settings' ), __( 'Settings', 'kama-clic-counter' ) ); … … 50 50 } 51 51 52 public function admin_menu() {52 public function admin_menu() { 53 53 54 54 // just in case … … 69 69 } 70 70 71 public function admin_page_load() {71 public function admin_page_load() { 72 72 73 73 // just in case... … … 96 96 is_string( $val ) && $val = trim( $val ); 97 97 98 if( $key === 'download_tpl' ){} // no sanitize... wp_kses($val, 'post'); 99 elseif( $key === 'url_exclude_patterns' ){} // no sanitize... 98 if( $key === 'download_tpl' ){ 99 // no sanitize... 100 } 101 elseif( $key === 'url_exclude_patterns' ){ 102 // no sanitize... wp_kses($val, 'post'); 103 } 104 // no sanitize... 100 105 elseif( is_array( $val ) ){ 101 106 $val = array_map( 'sanitize_key', $val ); … … 136 141 137 142 $data = wp_unslash( $_POST['up'] ); 138 $id = (int) $data['link_id'];143 $id = (int) $data['link_id']; 139 144 140 145 // очистка … … 210 215 * Callback for {@see add_options_page()} function parameter. 211 216 */ 212 public function options_page_output() {217 public function options_page_output() { 213 218 include plugin()->dir . '/admin/pages/admin.php'; 214 219 } 215 220 216 221 /** 217 * @param int $link_id218 * @param array $data219 *220 222 * @return int|false 221 223 */ 222 private function update_link( $link_id, $data ) { 223 global $wpdb; 224 225 $link_id = (int) $link_id; 224 private function update_link( int $link_id, array $data ) { 225 global $wpdb; 226 226 227 if( $link_id ){ 227 228 $query = $wpdb->update( $wpdb->kcc_clicks, $data, [ 'link_id' => $link_id ] ); … … 243 244 244 245 public function delete_link_url( $link_id ): string { 245 return add_query_arg( [ 'delete_link' => $link_id, '_wpnonce' => wp_create_nonce('delete_link') ] );246 return add_query_arg( [ 'delete_link' => $link_id, '_wpnonce' => wp_create_nonce( 'delete_link' ) ] ); 246 247 } 247 248 … … 249 250 * Deleting links from the database by passed array ID or link ID. 250 251 * 251 * @param array|int $array_idsIDs of links to be deleted.252 * @param array|int $array_ids IDs of links to be deleted. 252 253 */ 253 254 private function delete_links( $array_ids = [] ): bool { … … 263 264 } 264 265 265 public function delete_link_by_attach_id( $attach_id ) {266 public function delete_link_by_attach_id( $attach_id ) { 266 267 global $wpdb; 267 268 … … 276 277 * Update the link if the attachment is updated. 277 278 */ 278 public function update_link_with_attach( $attach_id ) {279 public function update_link_with_attach( $attach_id ) { 279 280 global $wpdb; 280 281 -
kama-clic-counter/trunk/src/Content_Replacer.php
r3056424 r3282892 5 5 class Content_Replacer { 6 6 7 public function __construct() {7 public function __construct() { 8 8 } 9 9 10 public function init() {10 public function init() { 11 11 12 12 if( plugin()->opt->links_class ){ … … 45 45 foreach( $args[0] as $pair ){ 46 46 list( $tag, $value ) = explode( '=', $pair, 2 ); 47 $value = trim( trim( $value, '"\'') );48 $args[ trim( $tag) ] = $value;47 $value = trim( trim( $value, '"\'' ) ); 48 $args[ trim( $tag ) ] = $value; 49 49 } 50 50 unset( $args[0], $args[1] ); 51 51 52 52 $after = ''; 53 $args[ 'data-' . Counter::PID_KEY ] = $post->ID;53 $args[ 'data-' . Counter::PID_KEY ] = $post->ID; 54 54 if( plugin()->opt->add_hits ){ 55 55 $link = plugin()->counter->get_link( $args['href'] ); -
kama-clic-counter/trunk/src/Counter.php
r3167383 r3282892 17 17 public $opt; 18 18 19 public function __construct( Options $options ) {19 public function __construct( Options $options ) { 20 20 21 21 $this->opt = $options; … … 95 95 * Hides the original link under the link ID. The link must exist in the database. 96 96 * 97 * @param string $kcc_url Plugin formated URL of the link counting.97 * @param string $kcc_url Plugin formated URL of the link counting. 98 98 * 99 99 * @return string URL with a hidden link. … … 368 368 else{ 369 369 trigger_error( sprintf( 'Error: kcc link with id %s not found.', $url ) ); 370 370 371 return; 371 372 } … … 399 400 400 401 // cut URL from $query, because - there could be query args (&) that is why cut it 401 $split = preg_split( '/[&?]?' . self::COUNT_KEY .'=/', $kcc_query );402 $split = preg_split( '/[&?]?' . self::COUNT_KEY . '=/', $kcc_query ); 402 403 $query = $split[0]; 403 $url = self::replace_url_placeholders( $split[1] ); // can be base64 encoded404 $url = self::replace_url_placeholders( $split[1] ); // can be base64 encoded 404 405 405 406 if( ! $url ){ … … 427 428 ! is_numeric( $url ) 428 429 && $url[0] !== '/' 429 && ! preg_match( '~^( ?:' . implode( '|', wp_allowed_protocols() ) . '):~', $url )430 ) {430 && ! preg_match( '~^(' . implode( '|', wp_allowed_protocols() ) . '):~', $url ) 431 ){ 431 432 return []; 432 433 } 433 434 434 435 $return = [ 435 self::COUNT_KEY => $url, // no esc_url()436 self::COUNT_KEY => $url, // !!! no esc_url() 436 437 self::PID_KEY => (int) ( $query_args[ self::PID_KEY ] ?? 0 ), 437 438 // array_key_exists( 'download', $query_args ), // isset null не берет … … 442 443 } 443 444 444 public static function del_http_protocol( $url ) {445 public static function del_http_protocol( $url ) { 445 446 return preg_replace( '/https?:/', '', $url ); 446 447 } 447 448 448 private function is_file( $url ) {449 private function is_file( $url ) { 449 450 /** 450 451 * Allows to repalce {@see Counter::is_file()} method. … … 537 538 $i = 0; 538 539 $type = [ "B", "KB", "MB", "GB" ]; 539 while( ( $size /1024 ) > 1 ){540 $size = $size /1024;540 while( ( $size / 1024 ) > 1 ){ 541 $size = $size / 1024; 541 542 $i++; 542 543 } … … 548 549 * Returns the size of a file without downloading it. 549 550 * 550 * @param string $url The location of the remote file to download. Cannot be null or empty.551 * @param string $url The location of the remote file to download. Cannot be null or empty. 551 552 * 552 553 * @return int The size of the file referenced by $url, or 0 if the size could not be determined. -
kama-clic-counter/trunk/src/Download_Shortcode.php
r3056424 r3282892 5 5 class Download_Shortcode { 6 6 7 public function __construct() {7 public function __construct() { 8 8 } 9 9 10 public function init() {10 public function init() { 11 11 add_shortcode( 'download', [ $this, 'download_shortcode' ] ); 12 12 } -
kama-clic-counter/trunk/src/Helpers.php
r3056424 r3282892 6 6 7 7 /** 8 * @param string $message MessageHTML.9 * @param string $type Allowed: success | error | warning |info.8 * @param string $message HTML. 9 * @param string $type One of: success|error|warning|info. 10 10 */ 11 11 public static function notice_message( string $message, string $type = 'warning' ) { 12 12 13 add_action( 14 'admin_notices', 15 function () use ( $message, $type ) { 16 ?> 17 <div id="message" class="notice <?= esc_attr( "notice-$type" ) ?>"> 18 <p><?= wp_kses_post( $message ) ?></p> 19 </div> 20 <?php 21 } 22 ); 13 add_action( 'admin_notices', function() use ( $message, $type ) { 14 ?> 15 <div id="message" class="notice <?= esc_attr( "notice-$type" ) ?>"> 16 <p><?= wp_kses_post( $message ) ?></p> 17 </div> 18 <?php 19 } ); 23 20 } 24 21 … … 26 23 * Gets a link to the icon image by the extension in the passed URL. 27 24 * 28 * @param $link_url29 *30 25 * @return mixed|null 31 26 */ 32 public static function get_icon_url( $link_url ) {27 public static function get_icon_url( $link_url ) { 33 28 34 29 $url_path = parse_url( $link_url, PHP_URL_PATH ); … … 37 32 $icon_name = $m[1] . '.png'; 38 33 } 39 else {34 else { 40 35 $icon_name = 'default.png'; 41 36 } -
kama-clic-counter/trunk/src/Options.php
r3056424 r3282892 49 49 ', 50 50 // css class for links in content (if not specified, this functionality is disabled). 51 'links_class' => 'count',51 'links_class' => 'count', 52 52 // may be: '', 'in_title' or 'in_plain' (for simple links) 53 53 'add_hits' => '', -
kama-clic-counter/trunk/src/Plugin.php
r3056424 r3282892 42 42 43 43 public function __construct( string $main_file_path ) { 44 45 44 $this->set_wpdb_tables(); 46 45 … … 50 49 $this->url = plugins_url( '', $main_file_path ); 51 50 52 $this->info = get_file_data( 53 $main_file_path, 54 [ 55 'name' => 'Plugin Name', 56 'version' => 'Version', 57 'php_ver' => 'Requires PHP', 58 ] 59 ); 51 $this->info = get_file_data( $main_file_path, [ 52 'name' => 'Plugin Name', 53 'version' => 'Version', 54 'php_ver' => 'Requires PHP', 55 ] ); 60 56 61 57 $this->opt = new Options(); 62 58 } 63 59 64 /** 65 * The plugin initialization. Performs on `plugins_loaded` hook. 66 * 67 * @return void 68 */ 69 public function init() { 60 public function init(): void { 70 61 71 if ( ! $this->check_dependencies() ){62 if( ! $this->check_dependencies() ){ 72 63 return; 73 64 } … … 107 98 } 108 99 109 /** 110 * @return void 111 */ 112 private function set_admin_access() { 100 private function set_admin_access(): void { 113 101 $this->admin_access = current_user_can( 'manage_options' ); 114 102 } 115 103 116 /** 117 * @return void 118 */ 119 private function set_manage_access() { 104 private function set_manage_access(): void { 120 105 121 106 $this->manage_access = apply_filters( 'kcc_manage_access', null ); … … 139 124 } 140 125 141 public function add_toolbar_menu( $toolbar ) {126 public function add_toolbar_menu( $toolbar ) { 142 127 143 128 $toolbar->add_menu( [ … … 149 134 150 135 public function check_dependencies(): bool { 151 152 if ( version_compare( PHP_VERSION, $this->info['php_ver'], '<=' ) ) { 153 136 if( version_compare( PHP_VERSION, $this->info['php_ver'], '<=' ) ){ 154 137 Helpers::notice_message( 155 138 '<b>Kama Click Counter</b> plugin requires PHP version <b>' . $this->info['php_ver'] . '</b> or higher. Please upgrade PHP or diactivate the plugin.', … … 163 146 } 164 147 165 public function activation() {148 public function activation() { 166 149 global $wpdb; 167 150 168 if ( ! $this->check_dependencies() ){151 if( ! $this->check_dependencies() ){ 169 152 return; 170 153 } -
kama-clic-counter/trunk/src/TinyMCE.php
r3056424 r3282892 21 21 22 22 public static function register_buttons( $buttons ) { 23 $last = array_pop( $buttons );23 $last = array_pop( $buttons ); 24 24 $buttons[] = 'kcc'; 25 25 $buttons[] = $last; -
kama-clic-counter/trunk/src/Upgrader.php
r3056424 r3282892 22 22 private $db_fields; 23 23 24 public function __construct() {25 $this->is_force_upgrade = isset( $_GET['kcc_force_upgrade'] );24 public function __construct() { 25 $this->is_force_upgrade = isset( $_GET['kcc_force_upgrade'] ); 26 26 27 $this->prev_ver = $this->is_force_upgrade ? '1.0' : get_option( self::OPTION_NAME, '1.0' );28 $this->curr_ver = plugin()->info['version'];27 $this->prev_ver = $this->is_force_upgrade ? '1.0' : get_option( self::OPTION_NAME, '1.0' ); 28 $this->curr_ver = plugin()->info['version']; 29 29 } 30 30 … … 50 50 exit; 51 51 } 52 53 52 } 54 53 -
kama-clic-counter/trunk/src/Widget.php
r3056424 r3282892 13 13 } 14 14 15 public static function init() {15 public static function init() { 16 16 17 17 if( ! plugin()->opt->widget ){ … … 19 19 } 20 20 21 add_action( 'widgets_init', function () {21 add_action( 'widgets_init', function() { 22 22 register_widget( self::class ); 23 23 } ); … … 125 125 * Admin part of the widget 126 126 */ 127 public function form( $instance ){ 128 129 $title = @ $instance['title'] ? $instance[ 'title' ] : __('Top Downloads', 'kama-clic-counter' ); 130 $number = @ $instance['number'] ? $instance[ 'number' ] : 5; 131 $last_date = @ $instance['last_date'] ? $instance[ 'last_date' ] : ''; 132 $template_css = @ $instance['template_css'] 133 ? $instance[ 'template_css' ] 134 : preg_replace( 135 '~^\t+~m', '', '.kcc_widget{ padding:15px; } 136 .kcc_widget li{ margin-bottom:10px; list-style: none; } 137 .kcc_widget li:after{ content:""; display:table; clear:both; } 138 .kcc_widget img{ width:30px; float:left; margin:5px 10px 5px 0; } 139 .kcc_widget p{ margin-left:40px; }' 140 ); 141 142 $template = @ $instance['template'] 143 ? $instance['template'] 144 : '<img src="[icon_url]" alt="" />' . "\n" 145 . '<a href="[link_url]">[link_title]</a> ([link_clicks])' . "\n" 146 . '<p>[link_description]</p>'; 127 public function form( $instance ) { 128 129 $default_template_css = ' 130 .kcc_widget{ padding:15px; } 131 .kcc_widget li{ margin-bottom:10px; list-style: none; } 132 .kcc_widget li:after{ content:""; display:table; clear:both; } 133 .kcc_widget img{ width:30px; float:left; margin:5px 10px 5px 0; } 134 .kcc_widget p{ margin-left:40px; } 135 '; 136 137 $default_template = ' 138 <img src="[icon_url]" alt="" /> 139 <a href="[link_url]">[link_title]</a> ([link_clicks]) 140 <p>[link_description]</p> 141 '; 142 143 $title = $instance['title'] ?? __( 'Top Downloads', 'kama-clic-counter' ); 144 $number = $instance['number'] ?? 5; 145 $last_date = $instance['last_date'] ?? ''; 146 $template_css = $instance['template_css'] ?? preg_replace( '~^\t+~m', '', trim( $default_template_css ) ); 147 $template = $instance['template'] ?? preg_replace( '~^\t+~m', '', trim( $default_template ) ); 147 148 ?> 148 149 <p>
Note: See TracChangeset
for help on using the changeset viewer.