duplicate-post
Last commit date
compat
4 years ago
css
5 years ago
js
4 years ago
src
4 years ago
vendor
4 years ago
admin-functions.php
4 years ago
common-functions.php
4 years ago
duplicate-post.php
4 years ago
duplicate_post_yoast_icon-125x125.png
5 years ago
gpl-2.0.txt
14 years ago
options.php
4 years ago
readme.txt
4 years ago
duplicate-post.php
112 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Duplicate Post plugin. |
| 4 | * |
| 5 | * @package Yoast\WP\Duplicate_Post |
| 6 | * @since 0.1 |
| 7 | * |
| 8 | * @wordpress-plugin |
| 9 | * Plugin Name: Yoast Duplicate Post |
| 10 | * Plugin URI: https://yoast.com/wordpress/plugins/duplicate-post/ |
| 11 | * Description: The go-to tool for cloning posts and pages, including the powerful Rewrite & Republish feature. |
| 12 | * Version: 4.2 |
| 13 | * Author: Enrico Battocchi & Team Yoast |
| 14 | * Author URI: https://yoast.com |
| 15 | * Text Domain: duplicate-post |
| 16 | * |
| 17 | * Copyright 2020 Yoast BV (email : info@yoast.com) |
| 18 | * |
| 19 | * This program is free software; you can redistribute it and/or modify |
| 20 | * it under the terms of the GNU General Public License as published by |
| 21 | * the Free Software Foundation; either version 2 of the License, or |
| 22 | * (at your option) any later version. |
| 23 | * |
| 24 | * This program is distributed in the hope that it will be useful, |
| 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 27 | * GNU General Public License for more details. |
| 28 | * |
| 29 | * You should have received a copy of the GNU General Public License |
| 30 | * along with this program; if not, write to the Free Software |
| 31 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 32 | */ |
| 33 | |
| 34 | use Yoast\WP\Duplicate_Post\Duplicate_Post; |
| 35 | |
| 36 | if ( ! defined( 'ABSPATH' ) ) { |
| 37 | exit(); |
| 38 | } |
| 39 | |
| 40 | if ( ! defined( 'DUPLICATE_POST_FILE' ) ) { |
| 41 | define( 'DUPLICATE_POST_FILE', __FILE__ ); |
| 42 | } |
| 43 | |
| 44 | if ( ! defined( 'DUPLICATE_POST_PATH' ) ) { |
| 45 | define( 'DUPLICATE_POST_PATH', plugin_dir_path( __FILE__ ) ); |
| 46 | } |
| 47 | |
| 48 | define( 'DUPLICATE_POST_CURRENT_VERSION', '4.2' ); |
| 49 | |
| 50 | $duplicate_post_autoload_file = DUPLICATE_POST_PATH . 'vendor/autoload.php'; |
| 51 | |
| 52 | if ( is_readable( $duplicate_post_autoload_file ) ) { |
| 53 | require $duplicate_post_autoload_file; |
| 54 | } |
| 55 | |
| 56 | if ( class_exists( Duplicate_Post::class ) ) { |
| 57 | // Initialize the main autoloaded class. |
| 58 | add_action( 'plugins_loaded', '__duplicate_post_main' ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Loads the Duplicate Post main class. |
| 63 | * |
| 64 | * {@internal Function name change would be BC-break.} |
| 65 | * |
| 66 | * @phpcs:disable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore |
| 67 | * @phpcs:disable WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore |
| 68 | * @phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 69 | */ |
| 70 | function __duplicate_post_main() { |
| 71 | new Duplicate_Post(); |
| 72 | } |
| 73 | // phpcs:enable |
| 74 | |
| 75 | /** |
| 76 | * Initialises the internationalisation domain. |
| 77 | */ |
| 78 | function duplicate_post_load_plugin_textdomain() { |
| 79 | load_plugin_textdomain( 'duplicate-post', false, basename( __DIR__ ) . '/languages/' ); |
| 80 | } |
| 81 | add_action( 'plugins_loaded', 'duplicate_post_load_plugin_textdomain' ); |
| 82 | |
| 83 | add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'duplicate_post_plugin_actions', 10 ); |
| 84 | |
| 85 | /** |
| 86 | * Adds 'Settings' link to plugin entry in the Plugins list. |
| 87 | * |
| 88 | * @see 'plugin_action_links_$plugin_file' |
| 89 | * |
| 90 | * @param array $actions An array of plugin action links. |
| 91 | * @return array |
| 92 | */ |
| 93 | function duplicate_post_plugin_actions( $actions ) { |
| 94 | $settings_action = [ |
| 95 | 'settings' => sprintf( |
| 96 | '<a href="%1$s" %2$s>%3$s</a>', |
| 97 | menu_page_url( 'duplicatepost', false ), |
| 98 | 'aria-label="' . __( 'Settings for Duplicate Post', 'duplicate-post' ) . '"', |
| 99 | esc_html__( 'Settings', 'duplicate-post' ) |
| 100 | ), |
| 101 | ]; |
| 102 | |
| 103 | $actions = ( $settings_action + $actions ); |
| 104 | return $actions; |
| 105 | } |
| 106 | |
| 107 | require_once DUPLICATE_POST_PATH . 'common-functions.php'; |
| 108 | |
| 109 | if ( is_admin() ) { |
| 110 | include_once DUPLICATE_POST_PATH . 'admin-functions.php'; |
| 111 | } |
| 112 |