Changeset 2361962
- Timestamp:
- 08/15/2020 03:53:28 PM (5 years ago)
- Location:
- wp-pocket-urls
- Files:
-
- 6 edited
-
tags/1.0.0/assets/views/single-wp_pocketurl_link.php (modified) (1 diff)
-
tags/1.0.0/classes/class-wp-pocketurl-admin.php (modified) (2 diffs)
-
tags/1.0.0/classes/class-wp-pocketurl.php (modified) (3 diffs)
-
trunk/assets/views/single-wp_pocketurl_link.php (modified) (1 diff)
-
trunk/classes/class-wp-pocketurl-admin.php (modified) (2 diffs)
-
trunk/classes/class-wp-pocketurl.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-pocket-urls/tags/1.0.0/assets/views/single-wp_pocketurl_link.php
r2359978 r2361962 19 19 $clicks->count_click($post->ID); 20 20 } 21 22 21 switch($redirect){ 23 22 case '301': -
wp-pocket-urls/tags/1.0.0/classes/class-wp-pocketurl-admin.php
r2359978 r2361962 140 140 public function register_wp_pocketurl_settings(){ 141 141 add_settings_section( 'default_settings', '', array($this,'default_settings_callback'), 'wp_pocketurl_link_settings' ); 142 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_enable_auto' ); 143 add_settings_field( 'wp_pocketurl_link_enable_auto', 'Enable Published Posts External Link Auto Shortening', array($this,'wp_pocketurl_auto_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 144 145 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_prefix' ); 142 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_prefix' ); 146 143 add_settings_field( 'wp_pocketurl_link_prefix', 'Link Prefix', array($this,'wp_pocketurl_link_prefix_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 147 144 148 145 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_redirection' ); 149 add_settings_field( 'wp_pocketurl_link_redirection', ' Link Redirection', array($this,'wp_pocketurl_link_redirection_callback'), 'wp_pocketurl_link_settings', 'default_settings' );146 add_settings_field( 'wp_pocketurl_link_redirection', 'Default Link Redirection', array($this,'wp_pocketurl_link_redirection_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 150 147 151 148 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_collect_data' ); … … 155 152 add_settings_field( 'wp_pocketurl_link_exclude_cat', 'Do Not Add Category To Permalink', array($this,'wp_pocketurl_link_exclude_cat_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 156 153 157 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_exclude_word' ); 158 add_settings_field( 'wp_pocketurl_link_exclude_word', 'Banned URL String List', array($this,'wp_pocketurl_link_exclude_word_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 154 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_enable_auto' ); 155 add_settings_field( 'wp_pocketurl_link_enable_auto', 'Enable Published Posts External Link Auto Shortening', array($this,'wp_pocketurl_auto_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 156 157 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_exclude_word' ); 158 add_settings_field( 'wp_pocketurl_link_exclude_word', 'Auto Shortening Banned URL String List', array($this,'wp_pocketurl_link_exclude_word_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 159 159 160 160 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_require_word' ); 161 add_settings_field( 'wp_pocketurl_link_require_word', ' Required URL String List', array($this,'wp_pocketurl_link_required_word_callback'), 'wp_pocketurl_link_settings', 'default_settings' );161 add_settings_field( 'wp_pocketurl_link_require_word', 'Auto Shortening Required URL String List', array($this,'wp_pocketurl_link_required_word_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 162 162 } 163 163 // call back function for add settings section -
wp-pocket-urls/tags/1.0.0/classes/class-wp-pocketurl.php
r2359978 r2361962 12 12 } 13 13 14 register_activation_hook( __FILE__, 'wp_pocketurl_activate' ); 15 /** 16 * Add a flag that will allow to flush the rewrite rules when needed. 17 */ 18 function wp_pocketurl_activate() { 19 if ( ! get_option( 'wp_pocketurl_flush_rewrite_rules_flag' ) ) { 20 add_option( 'wp_pocketurl_flush_rewrite_rules_flag', true ); 21 } 22 } 23 24 add_action( 'init', 'wp_pocketurl_flush_rewrite_rules_maybe', 20 ); 25 /** 26 * Flush rewrite rules if the previously added flag exists, 27 * and then remove the flag. 28 */ 29 function wp_pocketurl_flush_rewrite_rules_maybe() { 30 if ( get_option( 'wp_pocketurl_flush_rewrite_rules_flag' ) ) { 31 flush_rewrite_rules(); 32 delete_option( 'wp_pocketurl_flush_rewrite_rules_flag' ); 33 } 34 } 35 36 register_deactivation_hook( __FILE__, 'wp_pocketurl_flush_rewrite_rules' ); 37 function wp_pocketurl_flush_rewrite_rules() 38 { 39 flush_rewrite_rules(); 40 } 41 14 42 class WP_PocketURLs{ 15 43 16 44 function __construct() { 17 45 //register custom post 18 add_action( 'init', array($this, 'wp_pocketurl_link_init'),0 );46 add_action( 'init', array($this, 'wp_pocketurl_link_init'),0 ); 19 47 //register custom taxonomy 20 add_action( 'init', array($this, 'wp_pocketurl_link_category_init'), 0 );48 add_action( 'init', array($this, 'wp_pocketurl_link_category_init'), 0 ); 21 49 //register link options box 22 add_action( 'add_meta_boxes', array($this, 'wp_pocketurl_link_options_init'), 0 );50 add_action( 'add_meta_boxes', array($this, 'wp_pocketurl_link_options_init'), 0 ); 23 51 // register link clicks details box 24 add_action( 'add_meta_boxes', array($this, 'wp_pocketurl_link_clicks_details_init'), 0 );52 add_action( 'add_meta_boxes', array($this, 'wp_pocketurl_link_clicks_details_init'), 0 ); 25 53 // save link options data 26 add_action( 'save_post',array($this, 'wp_pocketurl_link_options_save'));54 add_action( 'save_post',array($this, 'wp_pocketurl_link_options_save')); 27 55 // delete click data when post deleted 28 add_action( 'before_delete_post', array($this, 'wp_pocketurl_delete_click_data') );56 add_action( 'before_delete_post', array($this, 'wp_pocketurl_delete_click_data') ); 29 57 //enqueue scripts and styles 30 add_action('admin_enqueue_scripts',array($this, 'enqueue_styles'));31 add_action('admin_enqueue_scripts',array($this, 'enqueue_scripts'));58 add_action('admin_enqueue_scripts',array($this, 'enqueue_styles')); 59 add_action('admin_enqueue_scripts',array($this, 'enqueue_scripts')); 32 60 //hook the single post template 33 add_filter('single_template', array($this,'wp_pocketurl_link_template')); 34 61 add_filter('single_template', array($this, 'wp_pocketurl_link_template')); 35 62 } 36 63 … … 130 157 $args['rewrite'] = $rewrite; 131 158 register_post_type( 'wp_pocketurl_link', $args ); 159 flush_rewrite_rules(); 132 160 } 133 161 // register taxonomy … … 207 235 208 236 function wp_pocketurl_link_template($single){ 209 global $wp_query, $post; 237 global $post; 238 210 239 /* Checks for single template by post type */ 211 240 if ($post->post_type == "wp_pocketurl_link"){ 212 241 if(file_exists(wp_pocketurl_path . 'assets/views/single-wp_pocketurl_link.php')) 242 { 213 243 return wp_pocketurl_path . 'assets/views/single-wp_pocketurl_link.php'; 244 } 214 245 } 215 246 return $single; -
wp-pocket-urls/trunk/assets/views/single-wp_pocketurl_link.php
r2359978 r2361962 19 19 $clicks->count_click($post->ID); 20 20 } 21 22 21 switch($redirect){ 23 22 case '301': -
wp-pocket-urls/trunk/classes/class-wp-pocketurl-admin.php
r2359978 r2361962 140 140 public function register_wp_pocketurl_settings(){ 141 141 add_settings_section( 'default_settings', '', array($this,'default_settings_callback'), 'wp_pocketurl_link_settings' ); 142 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_enable_auto' ); 143 add_settings_field( 'wp_pocketurl_link_enable_auto', 'Enable Published Posts External Link Auto Shortening', array($this,'wp_pocketurl_auto_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 144 145 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_prefix' ); 142 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_prefix' ); 146 143 add_settings_field( 'wp_pocketurl_link_prefix', 'Link Prefix', array($this,'wp_pocketurl_link_prefix_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 147 144 148 145 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_redirection' ); 149 add_settings_field( 'wp_pocketurl_link_redirection', ' Link Redirection', array($this,'wp_pocketurl_link_redirection_callback'), 'wp_pocketurl_link_settings', 'default_settings' );146 add_settings_field( 'wp_pocketurl_link_redirection', 'Default Link Redirection', array($this,'wp_pocketurl_link_redirection_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 150 147 151 148 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_collect_data' ); … … 155 152 add_settings_field( 'wp_pocketurl_link_exclude_cat', 'Do Not Add Category To Permalink', array($this,'wp_pocketurl_link_exclude_cat_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 156 153 157 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_exclude_word' ); 158 add_settings_field( 'wp_pocketurl_link_exclude_word', 'Banned URL String List', array($this,'wp_pocketurl_link_exclude_word_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 154 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_enable_auto' ); 155 add_settings_field( 'wp_pocketurl_link_enable_auto', 'Enable Published Posts External Link Auto Shortening', array($this,'wp_pocketurl_auto_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 156 157 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_exclude_word' ); 158 add_settings_field( 'wp_pocketurl_link_exclude_word', 'Auto Shortening Banned URL String List', array($this,'wp_pocketurl_link_exclude_word_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 159 159 160 160 register_setting( 'wp_pocketurl_settings_group', 'wp_pocketurl_link_require_word' ); 161 add_settings_field( 'wp_pocketurl_link_require_word', ' Required URL String List', array($this,'wp_pocketurl_link_required_word_callback'), 'wp_pocketurl_link_settings', 'default_settings' );161 add_settings_field( 'wp_pocketurl_link_require_word', 'Auto Shortening Required URL String List', array($this,'wp_pocketurl_link_required_word_callback'), 'wp_pocketurl_link_settings', 'default_settings' ); 162 162 } 163 163 // call back function for add settings section -
wp-pocket-urls/trunk/classes/class-wp-pocketurl.php
r2359978 r2361962 12 12 } 13 13 14 register_activation_hook( __FILE__, 'wp_pocketurl_activate' ); 15 /** 16 * Add a flag that will allow to flush the rewrite rules when needed. 17 */ 18 function wp_pocketurl_activate() { 19 if ( ! get_option( 'wp_pocketurl_flush_rewrite_rules_flag' ) ) { 20 add_option( 'wp_pocketurl_flush_rewrite_rules_flag', true ); 21 } 22 } 23 24 add_action( 'init', 'wp_pocketurl_flush_rewrite_rules_maybe', 20 ); 25 /** 26 * Flush rewrite rules if the previously added flag exists, 27 * and then remove the flag. 28 */ 29 function wp_pocketurl_flush_rewrite_rules_maybe() { 30 if ( get_option( 'wp_pocketurl_flush_rewrite_rules_flag' ) ) { 31 flush_rewrite_rules(); 32 delete_option( 'wp_pocketurl_flush_rewrite_rules_flag' ); 33 } 34 } 35 36 register_deactivation_hook( __FILE__, 'wp_pocketurl_flush_rewrite_rules' ); 37 function wp_pocketurl_flush_rewrite_rules() 38 { 39 flush_rewrite_rules(); 40 } 41 14 42 class WP_PocketURLs{ 15 43 16 44 function __construct() { 17 45 //register custom post 18 add_action( 'init', array($this, 'wp_pocketurl_link_init'),0 );46 add_action( 'init', array($this, 'wp_pocketurl_link_init'),0 ); 19 47 //register custom taxonomy 20 add_action( 'init', array($this, 'wp_pocketurl_link_category_init'), 0 );48 add_action( 'init', array($this, 'wp_pocketurl_link_category_init'), 0 ); 21 49 //register link options box 22 add_action( 'add_meta_boxes', array($this, 'wp_pocketurl_link_options_init'), 0 );50 add_action( 'add_meta_boxes', array($this, 'wp_pocketurl_link_options_init'), 0 ); 23 51 // register link clicks details box 24 add_action( 'add_meta_boxes', array($this, 'wp_pocketurl_link_clicks_details_init'), 0 );52 add_action( 'add_meta_boxes', array($this, 'wp_pocketurl_link_clicks_details_init'), 0 ); 25 53 // save link options data 26 add_action( 'save_post',array($this, 'wp_pocketurl_link_options_save'));54 add_action( 'save_post',array($this, 'wp_pocketurl_link_options_save')); 27 55 // delete click data when post deleted 28 add_action( 'before_delete_post', array($this, 'wp_pocketurl_delete_click_data') );56 add_action( 'before_delete_post', array($this, 'wp_pocketurl_delete_click_data') ); 29 57 //enqueue scripts and styles 30 add_action('admin_enqueue_scripts',array($this, 'enqueue_styles'));31 add_action('admin_enqueue_scripts',array($this, 'enqueue_scripts'));58 add_action('admin_enqueue_scripts',array($this, 'enqueue_styles')); 59 add_action('admin_enqueue_scripts',array($this, 'enqueue_scripts')); 32 60 //hook the single post template 33 add_filter('single_template', array($this,'wp_pocketurl_link_template')); 34 61 add_filter('single_template', array($this, 'wp_pocketurl_link_template')); 35 62 } 36 63 … … 130 157 $args['rewrite'] = $rewrite; 131 158 register_post_type( 'wp_pocketurl_link', $args ); 159 flush_rewrite_rules(); 132 160 } 133 161 // register taxonomy … … 207 235 208 236 function wp_pocketurl_link_template($single){ 209 global $wp_query, $post; 237 global $post; 238 210 239 /* Checks for single template by post type */ 211 240 if ($post->post_type == "wp_pocketurl_link"){ 212 241 if(file_exists(wp_pocketurl_path . 'assets/views/single-wp_pocketurl_link.php')) 242 { 213 243 return wp_pocketurl_path . 'assets/views/single-wp_pocketurl_link.php'; 244 } 214 245 } 215 246 return $single;
Note: See TracChangeset
for help on using the changeset viewer.