wpCentral - Version 1.4.7

Version Description

  • [Bug Fix] : Featured Image was not published while publishing the post using wpCentral
  • [Bug Fix] : When a draft post was published using wpCentral, it created a new post instead of publishing the existing one.
Download this release

Release Info

Developer softacpriya
Plugin Icon 128x128 wpCentral
Version 1.4.7
Comparing to
See all releases

Code changes from version 1.4.6 to 1.4.7

Files changed (4) hide show
  1. actions.php +63 -1
  2. get_site_data.php +1 -0
  3. readme.txt +6 -2
  4. wpcentral.php +1 -1
actions.php CHANGED
@@ -85,7 +85,59 @@ function wpc_site_actions(){
85
  );
86
 
87
  // Insert the post into the database
88
- $return['create_post_response'] = wp_insert_post($my_post);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
90
 
91
  if($request == 'delete_post'){
@@ -95,6 +147,16 @@ function wpc_site_actions(){
95
  // Delete the post from the database
96
  $return['delete_post_response'] = wp_delete_post($post_id);
97
  }
 
 
 
 
 
 
 
 
 
 
98
 
99
  if(wpc_optGET('plugins') || wpc_optGET('plugin')){
100
  $plugins = urldecode(wpc_optREQ('plugins'));
85
  );
86
 
87
  // Insert the post into the database
88
+ $create_post_response = wp_insert_post($my_post);
89
+
90
+ $post_featured_image = wpc_optPOST('featured_image');
91
+
92
+ if(!empty($create_post_response) && !empty($post_featured_image)){
93
+
94
+ $image_url = $post_featured_image; // Define the image URL here
95
+ $image_name = basename($image_url);
96
+ $upload_dir = wp_upload_dir(); // Set upload folder
97
+ $image_data = file_get_contents($image_url); // Get image data
98
+ $unique_file_name = wp_unique_filename($upload_dir['path'], $image_name); // Generate unique name
99
+ $filename = basename($unique_file_name); // Create image file name
100
+
101
+ // Check folder permission and define file location
102
+ if(wp_mkdir_p($upload_dir['path'])){
103
+ $file = $upload_dir['path'].'/'.$filename;
104
+ }else{
105
+ $file = $upload_dir['basedir'].'/'.$filename;
106
+ }
107
+
108
+ // Create the image file on the server
109
+ file_put_contents($file, $image_data);
110
+
111
+ // Check image file type
112
+ $wp_filetype = wp_check_filetype($filename, null);
113
+
114
+ // Set attachment data
115
+ $attachment = array(
116
+ 'post_mime_type' => $wp_filetype['type'],
117
+ 'post_title' => sanitize_file_name($filename),
118
+ 'post_content' => '',
119
+ 'post_status' => 'inherit'
120
+ );
121
+
122
+ $post_id = $create_post_response;
123
+
124
+ // Create the attachment
125
+ $attach_id = wp_insert_attachment($attachment, $file, $post_id);
126
+
127
+ // Include image.php
128
+ require_once(ABSPATH.'wp-admin/includes/image.php');
129
+
130
+ // Define attachment metadata
131
+ $attach_data = wp_generate_attachment_metadata($attach_id, $file);
132
+
133
+ // Assign metadata to attachment
134
+ wp_update_attachment_metadata($attach_id, $attach_data);
135
+
136
+ // And finally assign featured image to post
137
+ set_post_thumbnail($post_id, $attach_id);
138
+ }
139
+
140
+ $return['create_post_response'] = $create_post_response;
141
  }
142
 
143
  if($request == 'delete_post'){
147
  // Delete the post from the database
148
  $return['delete_post_response'] = wp_delete_post($post_id);
149
  }
150
+
151
+ if($request == 'publish_post'){
152
+
153
+ $post_id = wpc_optREQ('post_id');
154
+
155
+ $post_data = array('ID' => $post_id, 'post_status' => 'publish');
156
+
157
+ // Delete the post from the database
158
+ $return['publish_post_response'] = wp_update_post($post_data);
159
+ }
160
 
161
  if(wpc_optGET('plugins') || wpc_optGET('plugin')){
162
  $plugins = urldecode(wpc_optREQ('plugins'));
get_site_data.php CHANGED
@@ -44,6 +44,7 @@ function wpc_get_site_data(){
44
  foreach($all_posts as $postk => $postv){
45
  $user_data = get_user_by('id', $postv->post_author);
46
  $all_posts[$postk]->post_author = $user_data->data->display_name;
 
47
  }
48
 
49
  $return['all_posts'] = $all_posts;
44
  foreach($all_posts as $postk => $postv){
45
  $user_data = get_user_by('id', $postv->post_author);
46
  $all_posts[$postk]->post_author = $user_data->data->display_name;
47
+ $all_posts[$postk]->post_featured_image = get_the_post_thumbnail_url($all_posts[$postk]->ID, 'full');
48
  }
49
 
50
  $return['all_posts'] = $all_posts;
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: softaculous
3
  Tags: wpcentral, softaculous, sites, manage sites, backup, plugins, themes, manage wordpress,
4
  Requires at least: 4.4
5
- Tested up to: 5.2.4
6
  Requires PHP: 5.3
7
- Stable tag: 1.4.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -40,6 +40,10 @@ Should you have any suggestions to improve wpcentral, want to see some related f
40
 
41
  == Changelog ==
42
 
 
 
 
 
43
  = 1.4.6 =
44
  * wpCentral Post Management support
45
 
2
  Contributors: softaculous
3
  Tags: wpcentral, softaculous, sites, manage sites, backup, plugins, themes, manage wordpress,
4
  Requires at least: 4.4
5
+ Tested up to: 5.3
6
  Requires PHP: 5.3
7
+ Stable tag: 1.4.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
40
 
41
  == Changelog ==
42
 
43
+ = 1.4.7 =
44
+ * [Bug Fix] : Featured Image was not published while publishing the post using wpCentral
45
+ * [Bug Fix] : When a draft post was published using wpCentral, it created a new post instead of publishing the existing one.
46
+
47
  = 1.4.6 =
48
  * wpCentral Post Management support
49
 
wpcentral.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: wpCentral
4
  Plugin URI: https://wpcentral.co
5
  Description: wpCentral provides a centralized area where you can manage all your WordPress websites singularly, unitedly as well as efficiently.
6
- Version: 1.4.6
7
  Author: Softaculous Ltd.
8
  Author URI: https://wpcentral.co
9
  License: GPL2
3
  Plugin Name: wpCentral
4
  Plugin URI: https://wpcentral.co
5
  Description: wpCentral provides a centralized area where you can manage all your WordPress websites singularly, unitedly as well as efficiently.
6
+ Version: 1.4.7
7
  Author: Softaculous Ltd.
8
  Author URI: https://wpcentral.co
9
  License: GPL2