close

Plugin Directory

Changeset 2106226


Ignore:
Timestamp:
06/14/2019 12:41:15 PM (7 years ago)
Author:
nathanrice
Message:

Tagging 0.9.8

Location:
simple-urls
Files:
18 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • simple-urls/tags/0.9.8/Gruntfile.js

    r1256140 r2106226  
    1212        // Dependencies
    1313
    14         // PHP
     14        // I18n
    1515
    16         // Lint .php files for syntax errors
    17         phplint: {
    18             all: [ '*.php', 'lib/**/*.php' ]
    19         },
    20 
    21 
    22         // I18n
    23        
    2416        // Add text domain as last argument of i18n functions
    2517        addtextdomain: {
     
    4436                    '_x:1,2c,3d',
    4537                    '_ex:1,2c,3d',
    46                     '_n:1,2,4d', 
     38                    '_n:1,2,4d',
    4739                    '_nx:1,2,4c,5d',
    4840                    '_n_noop:1,2,3d',
    4941                    '_nx_noop:1,2,3c,4d',
    50                     'esc_attr__:1,2d', 
     42                    'esc_attr__:1,2d',
    5143                    'esc_html__:1,2d',
    52                     'esc_attr_e:1,2d', 
     44                    'esc_attr_e:1,2d',
    5345                    'esc_html_e:1,2d',
    54                     'esc_attr_x:1,2c,3d', 
     46                    'esc_attr_x:1,2c,3d',
    5547                    'esc_html_x:1,2c,3d'
    5648                ]
  • simple-urls/tags/0.9.8/package.json

    r1758248 r2106226  
    99  "devDependencies": {
    1010    "grunt": "*",
    11     "grunt-autoprefixer": "*",
    1211    "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": "*",
    2312    "grunt-wp-i18n": "*",
    2413    "load-grunt-tasks": "*"
     
    2918    "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.",
    3019    "author": "StudioPress",
    31     "authoruri": "http://www.studiopress.com/",
    32     "version": "0.9.7",
     20    "authoruri": "https://www.studiopress.com/",
     21    "version": "0.9.8",
    3322    "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",
    3524    "textdomain": "simple-urls"
    3625  }
  • simple-urls/tags/0.9.8/plugin.php

    r1758248 r2106226  
    11<?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
    59
    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
    712
    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 */
    1018
    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 
     19if ( ! defined( 'ABSPATH' ) ) {
     20    exit;
    23921}
    24022
    241 new SimpleURLs;
     23define( 'SIMPLE_URLS_DIR', plugin_dir_path( __FILE__ ) );
     24define( 'SIMPLE_URLS_URL', plugins_url( '', __FILE__ ) );
     25
     26require_once SIMPLE_URLS_DIR . '/includes/class-simple-urls.php';
     27
     28new Simple_Urls();
     29
     30if ( 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  
    11=== Plugin Name ===
    2 Contributors: nathanrice, studiopress
     2Contributors: nathanrice, studiopress, cliffpaulick, marksabbath, modernnerd
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
    44Tags: redirect, click tracking, custom post types
    55Requires at least: 3.0
    66Tested up to: 4.8.3
    7 Stable tag: 0.9.7
     7Stable tag: 0.9.8
    88
    99Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site.
     
    3737= Can I change the URL structure to use something other than /go/ ??? =
    3838
    39 No, not without modifying the plugin.
     39Yes, by using the filter `simple_urls_slug`.
     40
     41Usage:
     42```
     43add_filter( 'simple_urls_slug', function(){
     44    return 'redirect-me';
     45});
     46```
    4047
    4148== Screenshots ==
     
    4552
    4653== 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.
    4762
    4863= 0.9.7 =
     
    7590= 0.9 =
    7691* Initial Beta Release
    77 
  • simple-urls/trunk/Gruntfile.js

    r1256140 r2106226  
    1212        // Dependencies
    1313
    14         // PHP
     14        // I18n
    1515
    16         // Lint .php files for syntax errors
    17         phplint: {
    18             all: [ '*.php', 'lib/**/*.php' ]
    19         },
    20 
    21 
    22         // I18n
    23        
    2416        // Add text domain as last argument of i18n functions
    2517        addtextdomain: {
     
    4436                    '_x:1,2c,3d',
    4537                    '_ex:1,2c,3d',
    46                     '_n:1,2,4d', 
     38                    '_n:1,2,4d',
    4739                    '_nx:1,2,4c,5d',
    4840                    '_n_noop:1,2,3d',
    4941                    '_nx_noop:1,2,3c,4d',
    50                     'esc_attr__:1,2d', 
     42                    'esc_attr__:1,2d',
    5143                    'esc_html__:1,2d',
    52                     'esc_attr_e:1,2d', 
     44                    'esc_attr_e:1,2d',
    5345                    'esc_html_e:1,2d',
    54                     'esc_attr_x:1,2c,3d', 
     46                    'esc_attr_x:1,2c,3d',
    5547                    'esc_html_x:1,2c,3d'
    5648                ]
  • simple-urls/trunk/package.json

    r1758248 r2106226  
    99  "devDependencies": {
    1010    "grunt": "*",
    11     "grunt-autoprefixer": "*",
    1211    "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": "*",
    2312    "grunt-wp-i18n": "*",
    2413    "load-grunt-tasks": "*"
     
    2918    "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.",
    3019    "author": "StudioPress",
    31     "authoruri": "http://www.studiopress.com/",
    32     "version": "0.9.7",
     20    "authoruri": "https://www.studiopress.com/",
     21    "version": "0.9.8",
    3322    "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",
    3524    "textdomain": "simple-urls"
    3625  }
  • simple-urls/trunk/plugin.php

    r1758248 r2106226  
    11<?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
    59
    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
    712
    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 */
    1018
    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 
     19if ( ! defined( 'ABSPATH' ) ) {
     20    exit;
    23921}
    24022
    241 new SimpleURLs;
     23define( 'SIMPLE_URLS_DIR', plugin_dir_path( __FILE__ ) );
     24define( 'SIMPLE_URLS_URL', plugins_url( '', __FILE__ ) );
     25
     26require_once SIMPLE_URLS_DIR . '/includes/class-simple-urls.php';
     27
     28new Simple_Urls();
     29
     30if ( 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  
    11=== Plugin Name ===
    2 Contributors: nathanrice, studiopress
     2Contributors: nathanrice, studiopress, cliffpaulick, marksabbath, modernnerd
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
    44Tags: redirect, click tracking, custom post types
    55Requires at least: 3.0
    66Tested up to: 4.8.3
    7 Stable tag: 0.9.7
     7Stable tag: 0.9.8
    88
    99Simple URLs is a complete URL management system that allows you create, manage, and track outbound links from your site.
     
    3737= Can I change the URL structure to use something other than /go/ ??? =
    3838
    39 No, not without modifying the plugin.
     39Yes, by using the filter `simple_urls_slug`.
     40
     41Usage:
     42```
     43add_filter( 'simple_urls_slug', function(){
     44    return 'redirect-me';
     45});
     46```
    4047
    4148== Screenshots ==
     
    4552
    4653== 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.
    4762
    4863= 0.9.7 =
     
    7590= 0.9 =
    7691* Initial Beta Release
    77 
Note: See TracChangeset for help on using the changeset viewer.