Version Description
Download this release
Release Info
Code changes from version 1.4.2 to 1.4.3
- admin/include/admin-setting.php +25 -1
- admin/include/class.settings-api.php +22 -0
- htmega_addons_elementor.php +2 -2
- includes/class.htmega.php +10 -0
- includes/class.post-duplicator.php +155 -0
- includes/helper-function.php +3 -0
- readme.txt +4 -1
admin/include/admin-setting.php
CHANGED
@@ -662,6 +662,14 @@ class HTMega_Admin_Settings {
|
|
662 |
'default'=>'off',
|
663 |
'class'=>'htmega_table_row',
|
664 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
665 |
|
666 |
|
667 |
),
|
@@ -852,9 +860,25 @@ class HTMega_Admin_Settings {
|
|
852 |
),
|
853 |
|
854 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
855 |
|
856 |
-
// Third Party Addons
|
857 |
$third_party_element = array();
|
|
|
858 |
if( is_plugin_active('bbpress/bbpress.php') ) {
|
859 |
$third_party_element['htmega_thirdparty_element_tabs'][] = [
|
860 |
'name' => 'bbpress',
|
662 |
'default'=>'off',
|
663 |
'class'=>'htmega_table_row',
|
664 |
),
|
665 |
+
|
666 |
+
array(
|
667 |
+
'name' => 'postduplicator',
|
668 |
+
'label' => __( 'Post Duplicator', 'htmega-addons' ),
|
669 |
+
'type' => 'checkbox',
|
670 |
+
'default'=>'off',
|
671 |
+
'class'=>'htmega_table_row',
|
672 |
+
),
|
673 |
|
674 |
|
675 |
),
|
860 |
),
|
861 |
|
862 |
);
|
863 |
+
|
864 |
+
// Post Duplicator Condition
|
865 |
+
if( htmega_get_option( 'postduplicator', 'htmega_advance_element_tabs', 'off' ) === 'on' ){
|
866 |
+
$post_types = htmega_get_post_types( array('defaultadd'=>'all') );
|
867 |
+
if ( did_action( 'elementor/loaded' ) && defined( 'ELEMENTOR_VERSION' ) ) {
|
868 |
+
$post_types['elementor_library'] = esc_html__( 'Templates', 'htmega-addons' );
|
869 |
+
}
|
870 |
+
$settings_fields['htmega_general_tabs'][] = [
|
871 |
+
'name' => 'postduplicate_condition',
|
872 |
+
'label' => __( 'Post Duplicator Condition', 'htmega-addons' ),
|
873 |
+
'desc' => __( 'You can enable duplicator for individual post.', 'htmega-addons' ),
|
874 |
+
'type' => 'multiselect',
|
875 |
+
'default' => '',
|
876 |
+
'options' => $post_types,
|
877 |
+
];
|
878 |
+
}
|
879 |
|
|
|
880 |
$third_party_element = array();
|
881 |
+
// Third Party Addons
|
882 |
if( is_plugin_active('bbpress/bbpress.php') ) {
|
883 |
$third_party_element['htmega_thirdparty_element_tabs'][] = [
|
884 |
'name' => 'bbpress',
|
admin/include/class.settings-api.php
CHANGED
@@ -307,6 +307,28 @@ class HTMega_Settings_API {
|
|
307 |
echo $html;
|
308 |
}
|
309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
/**
|
311 |
* Displays a textarea for a settings field
|
312 |
*
|
307 |
echo $html;
|
308 |
}
|
309 |
|
310 |
+
/**
|
311 |
+
* Displays a multiselect for a settings field
|
312 |
+
*
|
313 |
+
* @param array $args settings field args
|
314 |
+
*/
|
315 |
+
function callback_multiselect( $args ) {
|
316 |
+
|
317 |
+
$value = $this->get_option( $args['id'], $args['section'], $args['std'] );
|
318 |
+
$html = sprintf( '<select multiple="multiple" class="%1$s" name="%1$s[%2$s][]" id="%1$s[%2$s]">', $args['section'], $args['id'] );
|
319 |
+
foreach ( $args['options'] as $key => $label ) {
|
320 |
+
$selected = '';
|
321 |
+
if( !empty( $value ) ){
|
322 |
+
$selected = in_array( $key, $value ) ? $key : '';
|
323 |
+
}
|
324 |
+
$html .= sprintf( '<option value="%1$s" %2$s>%3$s</option>', $key, selected( $selected, $key, false ), $label );
|
325 |
+
}
|
326 |
+
$html .= sprintf( '</select>' );
|
327 |
+
$html .= $this->get_field_description( $args );
|
328 |
+
|
329 |
+
echo $html;
|
330 |
+
}
|
331 |
+
|
332 |
/**
|
333 |
* Displays a textarea for a settings field
|
334 |
*
|
htmega_addons_elementor.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Plugin URI: http://demo.wphash.com/htmega/
|
6 |
* Author: HasThemes
|
7 |
* Author URI: https://hasthemes.com/
|
8 |
-
* Version: 1.4.
|
9 |
* License: GPL2
|
10 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
* Text Domain: htmega-addons
|
@@ -13,7 +13,7 @@
|
|
13 |
*/
|
14 |
|
15 |
if( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
|
16 |
-
define( 'HTMEGA_VERSION', '1.4.
|
17 |
define( 'HTMEGA_ADDONS_PL_ROOT', __FILE__ );
|
18 |
define( 'HTMEGA_ADDONS_PL_URL', plugins_url( '/', HTMEGA_ADDONS_PL_ROOT ) );
|
19 |
define( 'HTMEGA_ADDONS_PL_PATH', plugin_dir_path( HTMEGA_ADDONS_PL_ROOT ) );
|
5 |
* Plugin URI: http://demo.wphash.com/htmega/
|
6 |
* Author: HasThemes
|
7 |
* Author URI: https://hasthemes.com/
|
8 |
+
* Version: 1.4.3
|
9 |
* License: GPL2
|
10 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
* Text Domain: htmega-addons
|
13 |
*/
|
14 |
|
15 |
if( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
|
16 |
+
define( 'HTMEGA_VERSION', '1.4.3' );
|
17 |
define( 'HTMEGA_ADDONS_PL_ROOT', __FILE__ );
|
18 |
define( 'HTMEGA_ADDONS_PL_URL', plugins_url( '/', HTMEGA_ADDONS_PL_ROOT ) );
|
19 |
define( 'HTMEGA_ADDONS_PL_PATH', plugin_dir_path( HTMEGA_ADDONS_PL_ROOT ) );
|
includes/class.htmega.php
CHANGED
@@ -205,6 +205,16 @@ final class HTMega_Addons_Elementor {
|
|
205 |
require_once ( HTMEGA_ADDONS_PL_PATH . 'includes/widgets_control.php' );
|
206 |
require_once ( HTMEGA_ADDONS_PL_PATH . 'includes/class.htmega-icon-manager.php' );
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
// Extension Assest Management
|
209 |
require_once( HTMEGA_ADDONS_PL_PATH . 'extensions/class.enqueue_scripts.php' );
|
210 |
|
205 |
require_once ( HTMEGA_ADDONS_PL_PATH . 'includes/widgets_control.php' );
|
206 |
require_once ( HTMEGA_ADDONS_PL_PATH . 'includes/class.htmega-icon-manager.php' );
|
207 |
|
208 |
+
// Admin Required File
|
209 |
+
if( is_admin() ){
|
210 |
+
|
211 |
+
// Post Duplicator
|
212 |
+
if( htmega_get_option( 'postduplicator', 'htmega_advance_element_tabs', 'off' ) === 'on' ){
|
213 |
+
require_once ( HTMEGA_ADDONS_PL_PATH . 'includes/class.post-duplicator.php' );
|
214 |
+
}
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
// Extension Assest Management
|
219 |
require_once( HTMEGA_ADDONS_PL_PATH . 'extensions/class.enqueue_scripts.php' );
|
220 |
|
includes/class.post-duplicator.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
|
3 |
+
|
4 |
+
class HTMega_Post_Dupicator{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* [$_instance]
|
8 |
+
* @var null
|
9 |
+
*/
|
10 |
+
private static $_instance = null;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* [instance] Initializes a singleton instance
|
14 |
+
* @return [HTMega_Post_Dupicator]
|
15 |
+
*/
|
16 |
+
public static function instance() {
|
17 |
+
if ( is_null( self::$_instance ) ) {
|
18 |
+
self::$_instance = new self();
|
19 |
+
}
|
20 |
+
return self::$_instance;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* [__construct description]
|
25 |
+
*/
|
26 |
+
public function __construct(){
|
27 |
+
add_filter( 'admin_action_htmega_duplicate_post_as_draft', [ $this, 'duplicate' ] );
|
28 |
+
add_filter( 'post_row_actions', [ $this, 'row_actions' ], 10, 2 );
|
29 |
+
add_filter( 'page_row_actions', [ $this, 'row_actions' ], 10, 2 );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* [row_actions]
|
34 |
+
* @param $actions
|
35 |
+
* @param [string] $post Current Post
|
36 |
+
* @return [array] Row Action List
|
37 |
+
*/
|
38 |
+
public function row_actions( $actions, $post ){
|
39 |
+
|
40 |
+
$enable = htmega_get_option( 'postduplicate_condition', 'htmega_general_tabs', array('all') );
|
41 |
+
|
42 |
+
if ( current_user_can('edit_posts') && ( in_array( $post->post_type, $enable ) || in_array('all', $enable) ) ) {
|
43 |
+
$actionurl = admin_url('admin.php?action=htmega_duplicate_post_as_draft&post=' . $post->ID );
|
44 |
+
$url = wp_nonce_url( $actionurl, 'htmega_duplicate_nonce' );
|
45 |
+
$actions['htmegaduplicate'] = '<a href="'.$url.'" title="'.esc_attr__( 'HT Mega Duplicator', 'htmega-addons' ).'" rel="permalink">'.esc_html__( 'HT Duplicate', 'htmega-addons' ).'</a>';
|
46 |
+
|
47 |
+
}
|
48 |
+
return $actions;
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* [duplicate]
|
54 |
+
* @return [ERROR | Rediresct To Edit URL]
|
55 |
+
*/
|
56 |
+
public function duplicate(){
|
57 |
+
global $wpdb;
|
58 |
+
|
59 |
+
if (! ( isset( $_REQUEST['post']) || isset( $_REQUEST['post'] ) || ( isset( $_REQUEST['action'] ) && 'htmega_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
|
60 |
+
wp_die( 'No post to duplicate has been supplied!' );
|
61 |
+
}
|
62 |
+
|
63 |
+
/*
|
64 |
+
* Nonce verification
|
65 |
+
*/
|
66 |
+
if( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'htmega_duplicate_nonce' ) ) {
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
|
70 |
+
/*
|
71 |
+
* get the original post id
|
72 |
+
*/
|
73 |
+
$post_id = ( isset( $_REQUEST['post'] ) ? absint( $_REQUEST['post'] ) : Null );
|
74 |
+
/*
|
75 |
+
* and all the original post data then
|
76 |
+
*/
|
77 |
+
$post = sanitize_post( get_post( $post_id ), 'db' );
|
78 |
+
|
79 |
+
/*
|
80 |
+
* if you don't want current user to be the new post author,
|
81 |
+
* then change next couple of lines to this: $new_post_author = $post->post_author;
|
82 |
+
*/
|
83 |
+
$current_user = wp_get_current_user();
|
84 |
+
$new_post_author = $current_user->ID;
|
85 |
+
|
86 |
+
/*
|
87 |
+
* if post data exists, create the post duplicate
|
88 |
+
*/
|
89 |
+
if ( isset( $post ) && $post != null) {
|
90 |
+
|
91 |
+
/*
|
92 |
+
* new post data array
|
93 |
+
*/
|
94 |
+
$args = array(
|
95 |
+
'comment_status' => $post->comment_status,
|
96 |
+
'ping_status' => $post->ping_status,
|
97 |
+
'post_author' => $new_post_author,
|
98 |
+
'post_content' => $post->post_content,
|
99 |
+
'post_excerpt' => $post->post_excerpt,
|
100 |
+
'post_name' => $post->post_name,
|
101 |
+
'post_parent' => $post->post_parent,
|
102 |
+
'post_password' => $post->post_password,
|
103 |
+
'post_status' => 'draft',
|
104 |
+
'post_title' => $post->post_title,
|
105 |
+
'post_type' => $post->post_type,
|
106 |
+
'to_ping' => $post->to_ping,
|
107 |
+
'menu_order' => $post->menu_order
|
108 |
+
);
|
109 |
+
|
110 |
+
/*
|
111 |
+
* insert the post by wp_insert_post() function
|
112 |
+
*/
|
113 |
+
$new_post_id = wp_insert_post( $args );
|
114 |
+
|
115 |
+
if( ! is_wp_error( $new_post_id ) ) {
|
116 |
+
/*
|
117 |
+
* get all current post terms ad set them to the new post draft
|
118 |
+
*/
|
119 |
+
$taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag");
|
120 |
+
if( ! empty( $taxonomies ) && is_array( $taxonomies ) ) {
|
121 |
+
foreach ($taxonomies as $taxonomy) {
|
122 |
+
$post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
|
123 |
+
wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/*
|
128 |
+
* duplicate all post meta just in two SQL queries
|
129 |
+
*/
|
130 |
+
$post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
|
131 |
+
if ( is_array( $post_meta_infos ) && count( $post_meta_infos ) !=0) {
|
132 |
+
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
|
133 |
+
foreach ($post_meta_infos as $meta_info) {
|
134 |
+
$meta_key = $meta_info->meta_key;
|
135 |
+
if( $meta_key == '_wp_old_slug' ) continue;
|
136 |
+
$meta_value = addslashes($meta_info->meta_value);
|
137 |
+
$sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
|
138 |
+
}
|
139 |
+
$sql_query.= implode(" UNION ALL ", $sql_query_sel);
|
140 |
+
$wpdb->query($sql_query);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
$redirect_to = admin_url( 'post.php?action=edit&post=' . $new_post_id );
|
144 |
+
wp_safe_redirect( $redirect_to );
|
145 |
+
|
146 |
+
}else {
|
147 |
+
wp_die('Post creation failed, could not find original post: ' . $post_id);
|
148 |
+
}
|
149 |
+
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
HTMega_Post_Dupicator::instance();
|
includes/helper-function.php
CHANGED
@@ -108,6 +108,9 @@ if( !function_exists('htmega_get_post_types') ){
|
|
108 |
$_post_types = get_post_types( $post_type_args , 'objects' );
|
109 |
|
110 |
$post_types = [];
|
|
|
|
|
|
|
111 |
foreach ( $_post_types as $post_type => $object ) {
|
112 |
$post_types[ $post_type ] = $object->label;
|
113 |
}
|
108 |
$_post_types = get_post_types( $post_type_args , 'objects' );
|
109 |
|
110 |
$post_types = [];
|
111 |
+
if( !empty( $args['defaultadd'] ) ){
|
112 |
+
$post_types[ strtolower($args['defaultadd']) ] = ucfirst($args['defaultadd']);
|
113 |
+
}
|
114 |
foreach ( $_post_types as $post_type => $object ) {
|
115 |
$post_types[ $post_type ] = $object->label;
|
116 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: hasthemes, htplugins, devitemsllc
|
|
3 |
Tags: Elementor, Elementor Addons, Elementor Widgets, elementor page builder, Elementor Blocks
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 5.4.1
|
6 |
-
Stable tag: 1.4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -190,6 +190,9 @@ Visit [HasThemes](https://hasthemes.com/) for more details about HTML, Shopify a
|
|
190 |
|
191 |
== Changelog ==
|
192 |
|
|
|
|
|
|
|
193 |
= Version: 1.4.2 - Date: 2020-06-02 =
|
194 |
* Scroll Navigation addon Scoring issue has been solved.
|
195 |
* Admin popup console error issue has been solved.
|
3 |
Tags: Elementor, Elementor Addons, Elementor Widgets, elementor page builder, Elementor Blocks
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 5.4.1
|
6 |
+
Stable tag: 1.4.3
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
190 |
|
191 |
== Changelog ==
|
192 |
|
193 |
+
= Version: 1.4.3 - Date: 2020-06-17 =
|
194 |
+
* Post Duplicator Option Added.
|
195 |
+
|
196 |
= Version: 1.4.2 - Date: 2020-06-02 =
|
197 |
* Scroll Navigation addon Scoring issue has been solved.
|
198 |
* Admin popup console error issue has been solved.
|