Changeset 2106226
- Timestamp:
- 06/14/2019 12:41:15 PM (7 years ago)
- Location:
- simple-urls
- Files:
-
- 18 added
- 8 edited
- 1 copied
-
tags/0.9.8 (copied) (copied from simple-urls/trunk)
-
tags/0.9.8/.circleci (added)
-
tags/0.9.8/.circleci/config.yml (added)
-
tags/0.9.8/.editorconfig (added)
-
tags/0.9.8/Gruntfile.js (modified) (2 diffs)
-
tags/0.9.8/composer.json (added)
-
tags/0.9.8/composer.lock (added)
-
tags/0.9.8/includes (added)
-
tags/0.9.8/includes/class-simple-urls-admin.php (added)
-
tags/0.9.8/includes/class-simple-urls.php (added)
-
tags/0.9.8/package-lock.json (added)
-
tags/0.9.8/package.json (modified) (2 diffs)
-
tags/0.9.8/plugin.php (modified) (1 diff)
-
tags/0.9.8/readme.txt (modified) (4 diffs)
-
trunk/.circleci (added)
-
trunk/.circleci/config.yml (added)
-
trunk/.editorconfig (added)
-
trunk/Gruntfile.js (modified) (2 diffs)
-
trunk/composer.json (added)
-
trunk/composer.lock (added)
-
trunk/includes (added)
-
trunk/includes/class-simple-urls-admin.php (added)
-
trunk/includes/class-simple-urls.php (added)
-
trunk/package-lock.json (added)
-
trunk/package.json (modified) (2 diffs)
-
trunk/plugin.php (modified) (1 diff)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-urls/tags/0.9.8/Gruntfile.js
r1256140 r2106226 12 12 // Dependencies 13 13 14 // PHP14 // I18n 15 15 16 // Lint .php files for syntax errors17 phplint: {18 all: [ '*.php', 'lib/**/*.php' ]19 },20 21 22 // I18n23 24 16 // Add text domain as last argument of i18n functions 25 17 addtextdomain: { … … 44 36 '_x:1,2c,3d', 45 37 '_ex:1,2c,3d', 46 '_n:1,2,4d', 38 '_n:1,2,4d', 47 39 '_nx:1,2,4c,5d', 48 40 '_n_noop:1,2,3d', 49 41 '_nx_noop:1,2,3c,4d', 50 'esc_attr__:1,2d', 42 'esc_attr__:1,2d', 51 43 'esc_html__:1,2d', 52 'esc_attr_e:1,2d', 44 'esc_attr_e:1,2d', 53 45 'esc_html_e:1,2d', 54 'esc_attr_x:1,2c,3d', 46 'esc_attr_x:1,2c,3d', 55 47 'esc_html_x:1,2c,3d' 56 48 ] -
simple-urls/tags/0.9.8/package.json
r1758248 r2106226 9 9 "devDependencies": { 10 10 "grunt": "*", 11 "grunt-autoprefixer": "*",12 11 "grunt-checktextdomain": "*", 13 "grunt-contrib-cssmin": "*",14 "grunt-contrib-imagemin": "*",15 "grunt-contrib-jshint": "*",16 "grunt-contrib-uglify": "*",17 "grunt-contrib-watch": "*",18 "grunt-csscomb": "*",19 "grunt-jsbeautifier": "*",20 "grunt-jsvalidate": "*",21 "grunt-phplint": "*",22 "grunt-styledocco": "*",23 12 "grunt-wp-i18n": "*", 24 13 "load-grunt-tasks": "*" … … 29 18 "description": "Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site by using custom post types and 301 redirects.", 30 19 "author": "StudioPress", 31 "authoruri": "http ://www.studiopress.com/",32 "version": "0.9. 7",20 "authoruri": "https://www.studiopress.com/", 21 "version": "0.9.8", 33 22 "license": "GPL-2.0+", 34 "licenseuri": "http ://www.gnu.org/licenses/gpl-2.0.html",23 "licenseuri": "https://www.gnu.org/licenses/gpl-2.0.html", 35 24 "textdomain": "simple-urls" 36 25 } -
simple-urls/tags/0.9.8/plugin.php
r1758248 r2106226 1 1 <?php 2 /* 3 Plugin Name: Simple URLs 4 Plugin URI: http://www.studiopress.com/plugins/simple-urls 2 /** 3 * Plugin Name: Simple URLs 4 * Plugin URI: https://wordpress.org/plugins/simple-urls/ 5 * Description: Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site by using custom post types and 301 redirects. 6 * Author: Nathan Rice 7 * Author URI: http://www.nathanrice.net/ 8 * Version: 0.9.8 5 9 6 Description: Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site by using custom post types and 301 redirects. 10 * Text Domain: simple-urls 11 * Domain Path: /languages 7 12 8 Author: Nathan Rice 9 Author URI: http://www.nathanrice.net/ 13 * License: GNU General Public License v2.0 (or later) 14 * License URI: http://www.opensource.org/licenses/gpl-license.php 15 * 16 * @package simple-urls 17 */ 10 18 11 Version: 0.9.7 12 13 Text Domain: simple-urls 14 Domain Path: /languages 15 16 License: GNU General Public License v2.0 (or later) 17 License URI: http://www.opensource.org/licenses/gpl-license.php 18 */ 19 20 class SimpleURLs { 21 22 // Constructor 23 function __construct() { 24 25 //register_activation_hook( __FILE__, 'flush_rewrite_rules' ); 26 27 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); 28 29 add_action( 'init', array( $this, 'register_post_type' ) ); 30 add_action( 'manage_posts_custom_column', array( $this, 'columns_data' ) ); 31 add_filter( 'manage_edit-surl_columns', array( $this, 'columns_filter' ) ); 32 33 add_filter( 'post_updated_messages', array( $this, 'updated_message' ) ); 34 35 add_action( 'admin_menu', array( $this, 'add_meta_box' ) ); 36 add_action( 'save_post', array( $this, 'meta_box_save' ), 1, 2 ); 37 add_action( 'template_redirect', array( $this, 'count_and_redirect' ) ); 38 39 } 40 41 function load_textdomain() { 42 load_plugin_textdomain( 'simple-urls', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); 43 } 44 45 function register_post_type() { 46 47 $slug = 'surl'; 48 49 $labels = array( 50 'name' => __( 'Simple URLs', 'simple-urls' ), 51 'singular_name' => __( 'URL', 'simple-urls' ), 52 'add_new' => __( 'Add New', 'simple-urls' ), 53 'add_new_item' => __( 'Add New URL', 'simple-urls' ), 54 'edit' => __( 'Edit', 'simple-urls' ), 55 'edit_item' => __( 'Edit URL', 'simple-urls' ), 56 'new_item' => __( 'New URL', 'simple-urls' ), 57 'view' => __( 'View URL', 'simple-urls' ), 58 'view_item' => __( 'View URL', 'simple-urls' ), 59 'search_items' => __( 'Search URL', 'simple-urls' ), 60 'not_found' => __( 'No URLs found', 'simple-urls' ), 61 'not_found_in_trash' => __( 'No URLs found in Trash', 'simple-urls' ), 62 'messages' => array( 63 0 => '', // Unused. Messages start at index 1. 64 1 => __( 'URL updated. <a href="%s">View URL</a>', 'simple-urls' ), 65 2 => __( 'Custom field updated.', 'simple-urls' ), 66 3 => __( 'Custom field deleted.', 'simple-urls' ), 67 4 => __( 'URL updated.', 'simple-urls' ), 68 /* translators: %s: date and time of the revision */ 69 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s', 'simple-urls' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 70 6 => __( 'URL updated. <a href="%s">View URL</a>', 'simple-urls' ), 71 7 => __( 'URL saved.', 'simple-urls' ), 72 8 => __( 'URL submitted.', 'simple-urls' ), 73 9 => __( 'URL scheduled', 'simple-urls' ), 74 10 => __( 'URL draft updated.', 'simple-urls' ), 75 ), 76 ); 77 78 $labels = apply_filters( 'simple_urls_cpt_labels', $labels ); 79 80 $rewrite_slug = apply_filters( 'simple_urls_slug', 'go' ); 81 82 register_post_type( $slug, 83 array( 84 'labels' => $labels, 85 'public' => true, 86 'query_var' => true, 87 'menu_position' => 20, 88 'supports' => array( 'title' ), 89 'rewrite' => array( 'slug' => $rewrite_slug, 'with_front' => false ), 90 ) 91 ); 92 93 } 94 95 function columns_filter( $columns ) { 96 97 $columns = array( 98 'cb' => '<input type="checkbox" />', 99 'title' => __( 'Title', 'simple-urls' ), 100 'url' => __( 'Redirect to', 'simple-urls' ), 101 'permalink' => __( 'Permalink', 'simple-urls' ), 102 'clicks' => __( 'Clicks', 'simple-urls' ), 103 ); 104 105 return $columns; 106 107 } 108 109 function columns_data( $column ) { 110 111 global $post; 112 113 $url = get_post_meta( $post->ID, '_surl_redirect', true ); 114 $count = get_post_meta( $post->ID, '_surl_count', true ); 115 116 if ( 'url' == $column ) { 117 echo make_clickable( esc_url( $url ? $url : '' ) ); 118 } 119 elseif ( 'permalink' == $column ) { 120 echo make_clickable( get_permalink() ); 121 } 122 elseif ( 'clicks' == $column ) { 123 echo esc_html( $count ? $count : 0 ); 124 } 125 126 } 127 128 function updated_message( $messages ) { 129 130 $surl_object = get_post_type_object( 'surl' ); 131 $messages['surl'] = $surl_object->labels->messages; 132 133 if ( $permalink = get_permalink() ) { 134 foreach ( $messages['surl'] as $id => $message ) { 135 $messages['surl'][ $id ] = sprintf( $message, $permalink ); 136 } 137 } 138 139 return $messages; 140 141 } 142 143 function add_meta_box() { 144 add_meta_box( 'surl', __( 'URL Information', 'simple-urls' ), array( $this, 'meta_box' ), 'surl', 'normal', 'high' ); 145 } 146 147 function meta_box() { 148 149 global $post; 150 151 printf( '<input type="hidden" name="_surl_nonce" value="%s" />', wp_create_nonce( plugin_basename(__FILE__) ) ); 152 153 printf( '<p><label for="%s">%s</label></p>', '_surl_redirect', __( 'Redirect URI', 'simple-urls' ) ); 154 printf( '<p><input style="%s" type="text" name="%s" id="%s" value="%s" /></p>', 'width: 99%;', '_surl_redirect', '_surl_redirect', esc_attr( get_post_meta( $post->ID, '_surl_redirect', true ) ) ); 155 printf( '<p><span class="description">%s</span></p>', __( 'This is the URL that the Redirect Link you create on this page will redirect to when accessed in a web browser.', 'simple-urls' ) ); 156 157 $count = isset( $post->ID ) ? get_post_meta($post->ID, '_surl_count', true) : 0; 158 echo '<p>' . sprintf( __( 'This URL has been accessed %d times', 'simple-urls' ), esc_attr( $count ) ) . '</p>'; 159 160 } 161 162 function meta_box_save( $post_id, $post ) { 163 164 $key = '_surl_redirect'; 165 166 // verify the nonce 167 if ( ! isset( $_POST['_surl_nonce'] ) || ! wp_verify_nonce( $_POST['_surl_nonce'], plugin_basename( __FILE__ ) ) ) { 168 return; 169 } 170 171 // don't try to save the data under autosave, ajax, or future post. 172 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return; 173 if ( defined('DOING_AJAX') && DOING_AJAX ) return; 174 if ( defined('DOING_CRON') && DOING_CRON ) return; 175 176 // is the user allowed to edit the URL? 177 if ( ! current_user_can( 'edit_posts' ) || 'surl' != $post->post_type ) 178 return; 179 180 $value = isset( $_POST[ $key ] ) ? $_POST[ $key ] : ''; 181 182 if ( $value ) { 183 // save/update 184 update_post_meta( $post->ID, $key, $value ); 185 } else { 186 // delete if blank 187 delete_post_meta( $post->ID, $key ); 188 } 189 190 } 191 192 193 function count_and_redirect() { 194 195 if ( ! is_singular( 'surl' ) ) { 196 return; 197 } 198 199 global $wp_query; 200 201 // Update the count 202 $count = isset( $wp_query->post->ID ) ? get_post_meta( $wp_query->post->ID, '_surl_count', true ) : 0; 203 update_post_meta( $wp_query->post->ID, '_surl_count', $count + 1 ); 204 205 // Handle the redirect 206 $redirect = isset( $wp_query->post->ID ) ? get_post_meta( $wp_query->post->ID, '_surl_redirect', true ) : ''; 207 208 /** 209 * Filter the redirect URL. 210 * 211 * @since 0.9.5 212 * 213 * @param string $redirect The URL to redirect to. 214 * @param int $var The current click count. 215 */ 216 $redirect = apply_filters( 'simple_urls_redirect_url', $redirect, $count ); 217 218 /** 219 * Action hook that fires before the redirect. 220 * 221 * @since 0.9.5 222 * 223 * @param string $redirect The URL to redirect to. 224 * @param int $var The current click count. 225 */ 226 do_action( 'simple_urls_redirect', $redirect, $count ); 227 228 if ( ! empty( $redirect ) ) { 229 wp_redirect( esc_url_raw( $redirect ), 301); 230 exit; 231 } 232 else { 233 wp_redirect( home_url(), 302 ); 234 exit; 235 } 236 237 } 238 19 if ( ! defined( 'ABSPATH' ) ) { 20 exit; 239 21 } 240 22 241 new SimpleURLs; 23 define( 'SIMPLE_URLS_DIR', plugin_dir_path( __FILE__ ) ); 24 define( 'SIMPLE_URLS_URL', plugins_url( '', __FILE__ ) ); 25 26 require_once SIMPLE_URLS_DIR . '/includes/class-simple-urls.php'; 27 28 new Simple_Urls(); 29 30 if ( is_admin() ) { 31 require_once SIMPLE_URLS_DIR . '/includes/class-simple-urls-admin.php'; 32 new Simple_Urls_Admin(); 33 } -
simple-urls/tags/0.9.8/readme.txt
r1758248 r2106226 1 1 === Plugin Name === 2 Contributors: nathanrice, studiopress 2 Contributors: nathanrice, studiopress, cliffpaulick, marksabbath, modernnerd 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118 4 4 Tags: redirect, click tracking, custom post types 5 5 Requires at least: 3.0 6 6 Tested up to: 4.8.3 7 Stable tag: 0.9. 77 Stable tag: 0.9.8 8 8 9 9 Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site. … … 37 37 = Can I change the URL structure to use something other than /go/ ??? = 38 38 39 No, not without modifying the plugin. 39 Yes, by using the filter `simple_urls_slug`. 40 41 Usage: 42 ``` 43 add_filter( 'simple_urls_slug', function(){ 44 return 'redirect-me'; 45 }); 46 ``` 40 47 41 48 == Screenshots == … … 45 52 46 53 == Changelog == 54 55 = 0.9.8 = 56 * Coding standards. 57 * Added composer. 58 * Added Circle CI integration. 59 * Added new filter to change the slug. 60 * Added REST support to ensure Simple URLs appear in list when linking text. 61 * Added cast string to int to avoid type error. 47 62 48 63 = 0.9.7 = … … 75 90 = 0.9 = 76 91 * Initial Beta Release 77 -
simple-urls/trunk/Gruntfile.js
r1256140 r2106226 12 12 // Dependencies 13 13 14 // PHP14 // I18n 15 15 16 // Lint .php files for syntax errors17 phplint: {18 all: [ '*.php', 'lib/**/*.php' ]19 },20 21 22 // I18n23 24 16 // Add text domain as last argument of i18n functions 25 17 addtextdomain: { … … 44 36 '_x:1,2c,3d', 45 37 '_ex:1,2c,3d', 46 '_n:1,2,4d', 38 '_n:1,2,4d', 47 39 '_nx:1,2,4c,5d', 48 40 '_n_noop:1,2,3d', 49 41 '_nx_noop:1,2,3c,4d', 50 'esc_attr__:1,2d', 42 'esc_attr__:1,2d', 51 43 'esc_html__:1,2d', 52 'esc_attr_e:1,2d', 44 'esc_attr_e:1,2d', 53 45 'esc_html_e:1,2d', 54 'esc_attr_x:1,2c,3d', 46 'esc_attr_x:1,2c,3d', 55 47 'esc_html_x:1,2c,3d' 56 48 ] -
simple-urls/trunk/package.json
r1758248 r2106226 9 9 "devDependencies": { 10 10 "grunt": "*", 11 "grunt-autoprefixer": "*",12 11 "grunt-checktextdomain": "*", 13 "grunt-contrib-cssmin": "*",14 "grunt-contrib-imagemin": "*",15 "grunt-contrib-jshint": "*",16 "grunt-contrib-uglify": "*",17 "grunt-contrib-watch": "*",18 "grunt-csscomb": "*",19 "grunt-jsbeautifier": "*",20 "grunt-jsvalidate": "*",21 "grunt-phplint": "*",22 "grunt-styledocco": "*",23 12 "grunt-wp-i18n": "*", 24 13 "load-grunt-tasks": "*" … … 29 18 "description": "Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site by using custom post types and 301 redirects.", 30 19 "author": "StudioPress", 31 "authoruri": "http ://www.studiopress.com/",32 "version": "0.9. 7",20 "authoruri": "https://www.studiopress.com/", 21 "version": "0.9.8", 33 22 "license": "GPL-2.0+", 34 "licenseuri": "http ://www.gnu.org/licenses/gpl-2.0.html",23 "licenseuri": "https://www.gnu.org/licenses/gpl-2.0.html", 35 24 "textdomain": "simple-urls" 36 25 } -
simple-urls/trunk/plugin.php
r1758248 r2106226 1 1 <?php 2 /* 3 Plugin Name: Simple URLs 4 Plugin URI: http://www.studiopress.com/plugins/simple-urls 2 /** 3 * Plugin Name: Simple URLs 4 * Plugin URI: https://wordpress.org/plugins/simple-urls/ 5 * Description: Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site by using custom post types and 301 redirects. 6 * Author: Nathan Rice 7 * Author URI: http://www.nathanrice.net/ 8 * Version: 0.9.8 5 9 6 Description: Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site by using custom post types and 301 redirects. 10 * Text Domain: simple-urls 11 * Domain Path: /languages 7 12 8 Author: Nathan Rice 9 Author URI: http://www.nathanrice.net/ 13 * License: GNU General Public License v2.0 (or later) 14 * License URI: http://www.opensource.org/licenses/gpl-license.php 15 * 16 * @package simple-urls 17 */ 10 18 11 Version: 0.9.7 12 13 Text Domain: simple-urls 14 Domain Path: /languages 15 16 License: GNU General Public License v2.0 (or later) 17 License URI: http://www.opensource.org/licenses/gpl-license.php 18 */ 19 20 class SimpleURLs { 21 22 // Constructor 23 function __construct() { 24 25 //register_activation_hook( __FILE__, 'flush_rewrite_rules' ); 26 27 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); 28 29 add_action( 'init', array( $this, 'register_post_type' ) ); 30 add_action( 'manage_posts_custom_column', array( $this, 'columns_data' ) ); 31 add_filter( 'manage_edit-surl_columns', array( $this, 'columns_filter' ) ); 32 33 add_filter( 'post_updated_messages', array( $this, 'updated_message' ) ); 34 35 add_action( 'admin_menu', array( $this, 'add_meta_box' ) ); 36 add_action( 'save_post', array( $this, 'meta_box_save' ), 1, 2 ); 37 add_action( 'template_redirect', array( $this, 'count_and_redirect' ) ); 38 39 } 40 41 function load_textdomain() { 42 load_plugin_textdomain( 'simple-urls', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); 43 } 44 45 function register_post_type() { 46 47 $slug = 'surl'; 48 49 $labels = array( 50 'name' => __( 'Simple URLs', 'simple-urls' ), 51 'singular_name' => __( 'URL', 'simple-urls' ), 52 'add_new' => __( 'Add New', 'simple-urls' ), 53 'add_new_item' => __( 'Add New URL', 'simple-urls' ), 54 'edit' => __( 'Edit', 'simple-urls' ), 55 'edit_item' => __( 'Edit URL', 'simple-urls' ), 56 'new_item' => __( 'New URL', 'simple-urls' ), 57 'view' => __( 'View URL', 'simple-urls' ), 58 'view_item' => __( 'View URL', 'simple-urls' ), 59 'search_items' => __( 'Search URL', 'simple-urls' ), 60 'not_found' => __( 'No URLs found', 'simple-urls' ), 61 'not_found_in_trash' => __( 'No URLs found in Trash', 'simple-urls' ), 62 'messages' => array( 63 0 => '', // Unused. Messages start at index 1. 64 1 => __( 'URL updated. <a href="%s">View URL</a>', 'simple-urls' ), 65 2 => __( 'Custom field updated.', 'simple-urls' ), 66 3 => __( 'Custom field deleted.', 'simple-urls' ), 67 4 => __( 'URL updated.', 'simple-urls' ), 68 /* translators: %s: date and time of the revision */ 69 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s', 'simple-urls' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 70 6 => __( 'URL updated. <a href="%s">View URL</a>', 'simple-urls' ), 71 7 => __( 'URL saved.', 'simple-urls' ), 72 8 => __( 'URL submitted.', 'simple-urls' ), 73 9 => __( 'URL scheduled', 'simple-urls' ), 74 10 => __( 'URL draft updated.', 'simple-urls' ), 75 ), 76 ); 77 78 $labels = apply_filters( 'simple_urls_cpt_labels', $labels ); 79 80 $rewrite_slug = apply_filters( 'simple_urls_slug', 'go' ); 81 82 register_post_type( $slug, 83 array( 84 'labels' => $labels, 85 'public' => true, 86 'query_var' => true, 87 'menu_position' => 20, 88 'supports' => array( 'title' ), 89 'rewrite' => array( 'slug' => $rewrite_slug, 'with_front' => false ), 90 ) 91 ); 92 93 } 94 95 function columns_filter( $columns ) { 96 97 $columns = array( 98 'cb' => '<input type="checkbox" />', 99 'title' => __( 'Title', 'simple-urls' ), 100 'url' => __( 'Redirect to', 'simple-urls' ), 101 'permalink' => __( 'Permalink', 'simple-urls' ), 102 'clicks' => __( 'Clicks', 'simple-urls' ), 103 ); 104 105 return $columns; 106 107 } 108 109 function columns_data( $column ) { 110 111 global $post; 112 113 $url = get_post_meta( $post->ID, '_surl_redirect', true ); 114 $count = get_post_meta( $post->ID, '_surl_count', true ); 115 116 if ( 'url' == $column ) { 117 echo make_clickable( esc_url( $url ? $url : '' ) ); 118 } 119 elseif ( 'permalink' == $column ) { 120 echo make_clickable( get_permalink() ); 121 } 122 elseif ( 'clicks' == $column ) { 123 echo esc_html( $count ? $count : 0 ); 124 } 125 126 } 127 128 function updated_message( $messages ) { 129 130 $surl_object = get_post_type_object( 'surl' ); 131 $messages['surl'] = $surl_object->labels->messages; 132 133 if ( $permalink = get_permalink() ) { 134 foreach ( $messages['surl'] as $id => $message ) { 135 $messages['surl'][ $id ] = sprintf( $message, $permalink ); 136 } 137 } 138 139 return $messages; 140 141 } 142 143 function add_meta_box() { 144 add_meta_box( 'surl', __( 'URL Information', 'simple-urls' ), array( $this, 'meta_box' ), 'surl', 'normal', 'high' ); 145 } 146 147 function meta_box() { 148 149 global $post; 150 151 printf( '<input type="hidden" name="_surl_nonce" value="%s" />', wp_create_nonce( plugin_basename(__FILE__) ) ); 152 153 printf( '<p><label for="%s">%s</label></p>', '_surl_redirect', __( 'Redirect URI', 'simple-urls' ) ); 154 printf( '<p><input style="%s" type="text" name="%s" id="%s" value="%s" /></p>', 'width: 99%;', '_surl_redirect', '_surl_redirect', esc_attr( get_post_meta( $post->ID, '_surl_redirect', true ) ) ); 155 printf( '<p><span class="description">%s</span></p>', __( 'This is the URL that the Redirect Link you create on this page will redirect to when accessed in a web browser.', 'simple-urls' ) ); 156 157 $count = isset( $post->ID ) ? get_post_meta($post->ID, '_surl_count', true) : 0; 158 echo '<p>' . sprintf( __( 'This URL has been accessed %d times', 'simple-urls' ), esc_attr( $count ) ) . '</p>'; 159 160 } 161 162 function meta_box_save( $post_id, $post ) { 163 164 $key = '_surl_redirect'; 165 166 // verify the nonce 167 if ( ! isset( $_POST['_surl_nonce'] ) || ! wp_verify_nonce( $_POST['_surl_nonce'], plugin_basename( __FILE__ ) ) ) { 168 return; 169 } 170 171 // don't try to save the data under autosave, ajax, or future post. 172 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return; 173 if ( defined('DOING_AJAX') && DOING_AJAX ) return; 174 if ( defined('DOING_CRON') && DOING_CRON ) return; 175 176 // is the user allowed to edit the URL? 177 if ( ! current_user_can( 'edit_posts' ) || 'surl' != $post->post_type ) 178 return; 179 180 $value = isset( $_POST[ $key ] ) ? $_POST[ $key ] : ''; 181 182 if ( $value ) { 183 // save/update 184 update_post_meta( $post->ID, $key, $value ); 185 } else { 186 // delete if blank 187 delete_post_meta( $post->ID, $key ); 188 } 189 190 } 191 192 193 function count_and_redirect() { 194 195 if ( ! is_singular( 'surl' ) ) { 196 return; 197 } 198 199 global $wp_query; 200 201 // Update the count 202 $count = isset( $wp_query->post->ID ) ? get_post_meta( $wp_query->post->ID, '_surl_count', true ) : 0; 203 update_post_meta( $wp_query->post->ID, '_surl_count', $count + 1 ); 204 205 // Handle the redirect 206 $redirect = isset( $wp_query->post->ID ) ? get_post_meta( $wp_query->post->ID, '_surl_redirect', true ) : ''; 207 208 /** 209 * Filter the redirect URL. 210 * 211 * @since 0.9.5 212 * 213 * @param string $redirect The URL to redirect to. 214 * @param int $var The current click count. 215 */ 216 $redirect = apply_filters( 'simple_urls_redirect_url', $redirect, $count ); 217 218 /** 219 * Action hook that fires before the redirect. 220 * 221 * @since 0.9.5 222 * 223 * @param string $redirect The URL to redirect to. 224 * @param int $var The current click count. 225 */ 226 do_action( 'simple_urls_redirect', $redirect, $count ); 227 228 if ( ! empty( $redirect ) ) { 229 wp_redirect( esc_url_raw( $redirect ), 301); 230 exit; 231 } 232 else { 233 wp_redirect( home_url(), 302 ); 234 exit; 235 } 236 237 } 238 19 if ( ! defined( 'ABSPATH' ) ) { 20 exit; 239 21 } 240 22 241 new SimpleURLs; 23 define( 'SIMPLE_URLS_DIR', plugin_dir_path( __FILE__ ) ); 24 define( 'SIMPLE_URLS_URL', plugins_url( '', __FILE__ ) ); 25 26 require_once SIMPLE_URLS_DIR . '/includes/class-simple-urls.php'; 27 28 new Simple_Urls(); 29 30 if ( is_admin() ) { 31 require_once SIMPLE_URLS_DIR . '/includes/class-simple-urls-admin.php'; 32 new Simple_Urls_Admin(); 33 } -
simple-urls/trunk/readme.txt
r1758248 r2106226 1 1 === Plugin Name === 2 Contributors: nathanrice, studiopress 2 Contributors: nathanrice, studiopress, cliffpaulick, marksabbath, modernnerd 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118 4 4 Tags: redirect, click tracking, custom post types 5 5 Requires at least: 3.0 6 6 Tested up to: 4.8.3 7 Stable tag: 0.9. 77 Stable tag: 0.9.8 8 8 9 9 Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site. … … 37 37 = Can I change the URL structure to use something other than /go/ ??? = 38 38 39 No, not without modifying the plugin. 39 Yes, by using the filter `simple_urls_slug`. 40 41 Usage: 42 ``` 43 add_filter( 'simple_urls_slug', function(){ 44 return 'redirect-me'; 45 }); 46 ``` 40 47 41 48 == Screenshots == … … 45 52 46 53 == Changelog == 54 55 = 0.9.8 = 56 * Coding standards. 57 * Added composer. 58 * Added Circle CI integration. 59 * Added new filter to change the slug. 60 * Added REST support to ensure Simple URLs appear in list when linking text. 61 * Added cast string to int to avoid type error. 47 62 48 63 = 0.9.7 = … … 75 90 = 0.9 = 76 91 * Initial Beta Release 77
Note: See TracChangeset
for help on using the changeset viewer.