Changeset 2052013
- Timestamp:
- 03/17/2019 11:05:10 AM (5 years ago)
- Location:
- transform-my-post
- Files:
-
- 6 added
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
transform-my-post/trunk/README.md
r1825529 r2052013 3 3 [Transform My Post](https://wordpress.org/plugins/transform-my-post/) gives you the ability to change the post type of any post on your website in case you change your mind or make a mistake. 4 4 5 ## Donate6 7 In case you really like using this plugin and would like to support me, please consider [donating via PayPal](https://www.paypal.me/dtj27). Any amount is hugely appreciated and allows me to develop the plugin further. Thank you!8 9 5 ## Useful Links 10 6 11 7 - [Download Plugin](https://wordpress.org/plugins/transform-my-post/) 12 - [ Help with Translations](https://translate.wordpress.org/projects/wp-plugins/transform-my-post)8 - [](https://translate.wordpress.org/projects/wp-plugins/transform-my-post) 13 9 - [GitHub Repository](https://github.com/danieltj27/Transform-My-Post) 14 - [Personal Blog](https://www.danieltj.co.uk/)15 -
transform-my-post/trunk/readme.txt
r2018593 r2052013 1 1 === Transform My Post === 2 2 Contributors: danieltj 3 Tags: post s, post types, admin, pages, editing4 Requires at least: 4. 05 Tested up to: 5. 06 Stable tag: 1.53 Tags: post 4 Requires at least: 4. 5 Tested up to: 5. 6 Stable tag: 7 7 License: GNU GPL v3 8 8 License URI: https://www.gnu.org/licenses/gpl-3.0.html 9 Donate link: https://www.paypal.me/dtj2710 9 11 10 Transform your posts into different post types. … … 17 16 = Developers = 18 17 19 There are lots of action and filter hooks available to extend the functionality of this plugin. If you'd like more information on how to use them, take a look at the plugin Wiki on the [GitHub repository](https://github.com/danieltj27/Transform-My-Post/wiki).18 iki on the [GitHub repository](https://github.com/danieltj27/Transform-My-Post/wiki). 20 19 21 20 == Installation == … … 49 48 == Changelog == 50 49 51 Refer to the [GitHub repository](https://github.com/danieltj27/Transform-My-Post /releases) for more information on version history and updates.50 Refer to the [GitHub repository](https://github.com/danieltj27/Transform-My-Post. -
transform-my-post/trunk/transform-my-post.php
r2018593 r2052013 5 5 * Plugin URI: https://wordpress.org/plugins/transform-my-post/ 6 6 * Description: Transform your posts into different post types. 7 7 8 * Author: Daniel James 8 9 * Author URI: https://danieltj.uk/ 9 10 * Text Domain: transform-my-post 10 * Version: 1.511 11 */ 12 12 … … 29 29 30 30 if ( ! defined( 'ABSPATH' ) ) { 31 31 32 die(); 33 32 34 } 33 35 34 $Transform_My_Post =new Transform_My_Post;36 new Transform_My_Post; 35 37 36 38 class Transform_My_Post { 37 39 38 40 /** 39 * The plugin version. 40 * 41 * @since 1.0 42 * 43 * @var string 44 */ 45 protected static $version = '1.5'; 46 47 /** 48 * Transform my WordPress. 49 * 50 * @since 1.0 41 * Hook into WordPress. 51 42 * 52 43 * @return void … … 54 45 public function __construct() { 55 46 56 add_action( 'plugins_loaded', array( __CLASS__, 'load_text_domain' ), 10, 0 );57 47 add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_box' ), 10, 0 ); 58 48 add_action( 'save_post', array( __CLASS__, 'save_post_data' ), 10, 2 ); 59 49 60 add_filter( 'plugin_action_links', array( __CLASS__, 'add_donate_link' ), 10, 2 ); 61 62 } 63 64 /** 65 * Load the plugin text domain. 66 * 67 * @since 1.0 68 * 69 * @return void 70 */ 71 public static function load_text_domain() { 72 73 load_plugin_textdomain( 'transform-my-post', false, untrailingslashit( dirname( __FILE__ ) ) . '/languages' ); 74 75 } 76 77 /** 78 * Adds a donate link to the plugins table. 79 * 80 * @since 1.0 81 * @since 1.3 Updated the l10n functions. 82 * 83 * @param array $links A list of plugin links 84 * @param string $file The current plugin file. 85 * 86 * @return array $links 87 */ 88 public static function add_donate_link( $links, $file ) { 89 90 // Check if this is the current plugin 91 if ( 'transform-my-post/transform-my-post.php' == $file ) { 92 93 // Create the donate link 94 $donate_link = '<a href="https://www.paypal.me/dtj27" target="_blank">' . esc_html__( 'Donate', 'transform-my-post' ) . '</a>'; 95 96 // Add the link to the array 97 array_unshift( $links, $donate_link ); 98 99 } 100 101 return $links; 102 103 } 104 105 /** 106 * Gets all the public post types. 107 * 108 * @since 1.0 50 } 51 52 /** 53 * Get all the public post types. 109 54 * 110 55 * @return array $post_types An array of post types. … … 112 57 public static function get_post_types() { 113 58 114 // Fetch a ny custom post types59 // Fetch a 115 60 $get_custom_types = get_post_types( 116 61 array( … … 123 68 ); 124 69 125 // Setup the blank array126 70 $post_types = array(); 127 71 128 // Add the built in types129 72 $post_types[] = 'post'; 130 73 $post_types[] = 'page'; 131 74 132 // Loop through each custom post type133 75 foreach ( $get_custom_types as $key => $value ) { 134 76 135 // Add the custom post type136 77 $post_types[] = $value; 137 78 … … 156 97 * Adds the meta to the post screens. 157 98 * 158 * @since 1.0159 * @since 1.3 Updated l10n functions.160 * @since 1.5 Added block editor compatible flag.161 *162 99 * @return void 163 100 */ 164 101 public static function add_meta_box() { 165 102 166 // Get the post types167 103 $post_types = self::get_post_types(); 168 104 169 // Create the new meta box170 105 add_meta_box( 171 106 'transform_my_post', 172 107 esc_html__( 'Post Type', 'transform-my-post' ), 173 array( 174 __CLASS__, 175 'meta_box_content' 176 ), 108 array( __CLASS__, 'meta_box_content' ), 177 109 $post_types, 178 110 'side', 179 111 'default', 180 array( 181 '__block_editor_compatible_meta_box' => true 182 ) 112 array( '__block_editor_compatible_meta_box' => true ) 183 113 ); 184 114 … … 188 118 * Prints the setting on the post screens. 189 119 * 190 * @since 1.0191 * @since 1.3 Updated l10n functions.192 *193 120 * @param object $post WP_Post object of the current post. 194 121 * … … 197 124 public static function meta_box_content( $post ) { 198 125 199 // Get the post types200 126 $post_types = self::get_post_types(); 201 127 202 // Create the nonce 128 // Create the nonce 203 129 $transform_my_post_nonce = wp_create_nonce('transform_my_post_nonce'); 204 130 205 // Get the post type object206 131 $post_type = get_post_type_object( $post->post_type ); 207 132 … … 231 156 * current post data was fetched (formerly `get_posts`) and saved. 232 157 * 233 * @since 1.1234 * @since 1.2 Rewrote post update functions.235 *236 158 * @param string $post_id The current post ID. 237 159 * @param object $post_data The current post object. … … 243 165 global $wpdb; 244 166 245 // F etch the nonce and filter it167 // F 246 168 $transform_my_post_nonce = isset ( $_POST['transform_my_post_nonce'] ) ? sanitize_text_field( $_POST['transform_my_post_nonce'] ) : ''; 247 169 248 // Verify the nonce 170 // Verify the nonce 249 171 if ( wp_verify_nonce( $transform_my_post_nonce, 'transform_my_post_nonce' ) ) { 250 172 251 // Get the new post type 173 // Get the new post type 252 174 $new_type = isset ( $_POST['transform_my_post_option'] ) ? sanitize_text_field( $_POST['transform_my_post_option'] ) : false; 253 175 254 // Get the post types255 176 $post_types = self::get_post_types(); 256 177 257 // Has the post type changed and is valid178 // Has the post type changed 258 179 if ( $new_type !== $post_data->post_type && in_array( $new_type, $post_types ) ) { 259 180 … … 268 189 $new_type = apply_filters( 'transform_new_post_type', $new_type, $post_id ); 269 190 270 // Update the post type 191 // Update the post type 271 192 $wpdb->update( 272 193 $wpdb->prefix . 'posts',
Note: See TracChangeset
for help on using the changeset viewer.