Plugin Directory

Changeset 2052013

Timestamp:
03/17/2019 11:05:10 AM (5 years ago)
Author:
danieltj
Message:

Update Transform My Post to v2.0

Location:
transform-my-post
Files:
6 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • transform-my-post/trunk/README.md

    r1825529 r2052013  
    33[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.
    44
    5 ## Donate
    6 
    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 
    95## Useful Links
    106
    117- [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)
    139- [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  
    11=== Transform My Post ===
    22Contributors: danieltj
    3 Tags: posts, post types, admin, pages, editing
    4 Requires at least: 4.0
    5 Tested up to: 5.0
    6 Stable tag: 1.5
     3Tags: post
     4Requires at least: 4.
     5Tested up to: 5.
     6Stable tag:
    77License: GNU GPL v3
    88License URI: https://www.gnu.org/licenses/gpl-3.0.html
    9 Donate link: https://www.paypal.me/dtj27
    109
    1110Transform your posts into different post types.
     
    1716= Developers =
    1817
    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).
     18iki on the [GitHub repository](https://github.com/danieltj27/Transform-My-Post/wiki).
    2019
    2120== Installation ==
     
    4948== Changelog ==
    5049
    51 Refer to the [GitHub repository](https://github.com/danieltj27/Transform-My-Post/releases) for more information on version history and updates.
     50Refer to the [GitHub repository](https://github.com/danieltj27/Transform-My-Post.
  • transform-my-post/trunk/transform-my-post.php

    r2018593 r2052013  
    55 * Plugin URI: https://wordpress.org/plugins/transform-my-post/
    66 * Description: Transform your posts into different post types.
     7
    78 * Author: Daniel James
    89 * Author URI: https://danieltj.uk/
    910 * Text Domain: transform-my-post
    10  * Version: 1.5
    1111 */
    1212
     
    2929
    3030if ( ! defined( 'ABSPATH' ) ) {
     31
    3132    die();
     33
    3234}
    3335
    34 $Transform_My_Post = new Transform_My_Post;
     36new Transform_My_Post;
    3537
    3638class Transform_My_Post {
    3739
    3840    /**
    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.
    5142     *
    5243     * @return void
     
    5445    public function __construct() {
    5546
    56         add_action( 'plugins_loaded', array( __CLASS__, 'load_text_domain' ), 10, 0 );
    5747        add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_box' ), 10, 0 );
    5848        add_action( 'save_post', array( __CLASS__, 'save_post_data' ), 10, 2 );
    5949
    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.
    10954     *
    11055     * @return array $post_types An array of post types.
     
    11257    public static function get_post_types() {
    11358
    114         // Fetch any custom post types
     59        // Fetch a
    11560        $get_custom_types = get_post_types(
    11661            array(
     
    12368        );
    12469
    125         // Setup the blank array
    12670        $post_types = array();
    12771
    128         // Add the built in types
    12972        $post_types[] = 'post';
    13073        $post_types[] = 'page';
    13174
    132         // Loop through each custom post type
    13375        foreach ( $get_custom_types as $key => $value ) {
    13476
    135             // Add the custom post type
    13677            $post_types[] = $value;
    13778
     
    15697     * Adds the meta to the post screens.
    15798     *
    158      * @since 1.0
    159      * @since 1.3 Updated l10n functions.
    160      * @since 1.5 Added block editor compatible flag.
    161      *
    16299     * @return void
    163100     */
    164101    public static function add_meta_box() {
    165102
    166         // Get the post types
    167103        $post_types = self::get_post_types();
    168104
    169         // Create the new meta box
    170105        add_meta_box(
    171106            'transform_my_post',
    172107            esc_html__( 'Post Type', 'transform-my-post' ),
    173             array(
    174                 __CLASS__,
    175                 'meta_box_content'
    176             ),
     108            array( __CLASS__, 'meta_box_content' ),
    177109            $post_types,
    178110            'side',
    179111            'default',
    180             array(
    181                 '__block_editor_compatible_meta_box' => true
    182             )
     112            array( '__block_editor_compatible_meta_box' => true )
    183113        );
    184114
     
    188118     * Prints the setting on the post screens.
    189119     *
    190      * @since 1.0
    191      * @since 1.3 Updated l10n functions.
    192      *
    193120     * @param object $post WP_Post object of the current post.
    194121     *
     
    197124    public static function meta_box_content( $post ) {
    198125
    199         // Get the post types
    200126        $post_types = self::get_post_types();
    201127
    202         // Create the nonce
     128        // Create the nonce
    203129        $transform_my_post_nonce = wp_create_nonce('transform_my_post_nonce');
    204130
    205         // Get the post type object
    206131        $post_type = get_post_type_object( $post->post_type );
    207132
     
    231156     * current post data was fetched (formerly `get_posts`) and saved.
    232157     *
    233      * @since 1.1
    234      * @since 1.2 Rewrote post update functions.
    235      *
    236158     * @param string $post_id   The current post ID.
    237159     * @param object $post_data The current post object.
     
    243165        global $wpdb;
    244166
    245         // Fetch the nonce and filter it
     167        // F
    246168        $transform_my_post_nonce = isset ( $_POST['transform_my_post_nonce'] ) ? sanitize_text_field( $_POST['transform_my_post_nonce'] ) : '';
    247169
    248         // Verify the nonce
     170        // Verify the nonce
    249171        if ( wp_verify_nonce( $transform_my_post_nonce, 'transform_my_post_nonce' ) ) {
    250172
    251             // Get the new post type
     173            // Get the new post type
    252174            $new_type = isset ( $_POST['transform_my_post_option'] ) ? sanitize_text_field( $_POST['transform_my_post_option'] ) : false;
    253175
    254             // Get the post types
    255176            $post_types = self::get_post_types();
    256177
    257             // Has the post type changed and is valid
     178            // Has the post type changed
    258179            if ( $new_type !== $post_data->post_type && in_array( $new_type, $post_types ) ) {
    259180
     
    268189                $new_type = apply_filters( 'transform_new_post_type', $new_type, $post_id );
    269190
    270                 // Update the post type
     191                // Update the post type
    271192                $wpdb->update(
    272193                    $wpdb->prefix . 'posts',
Note: See TracChangeset for help on using the changeset viewer.