Changeset 3076247
- Timestamp:
- 04/24/2024 08:41:55 AM (22 months ago)
- Location:
- wp-stack-connect/trunk
- Files:
-
- 1 added
- 21 edited
-
README.md (modified) (1 diff)
-
includes/callback/class-wp-stack-connect-request.php (modified) (1 diff)
-
includes/callback/handler.php (modified) (1 diff)
-
includes/callback/module/connection.php (modified) (1 diff)
-
includes/callback/module/content-manager.php (modified) (2 diffs)
-
includes/callback/module/media.php (modified) (2 diffs)
-
includes/callback/module/post.php (modified) (3 diffs)
-
includes/callback/module/publisher.php (modified) (2 diffs)
-
includes/callback/request.php (modified) (1 diff)
-
includes/configuration/assets/js/wp-stack-connect-configuration.js (modified) (7 diffs)
-
includes/configuration/assets/js/wp-stack-connect-configuration.min.js (modified) (1 diff)
-
includes/configuration/class-wp-stack-connect-configuration.php (modified) (4 diffs)
-
includes/configuration/template/view-configuration.php (modified) (1 diff)
-
includes/core/class-wp-stack-connect-connection.php (modified) (4 diffs)
-
includes/core/class-wp-stack-connect-filesystem.php (modified) (2 diffs)
-
includes/functions/activity-log-function.php (modified) (2 diffs)
-
includes/functions/custom-function.php (modified) (4 diffs)
-
includes/wp/wp_config_manager.php (added)
-
init.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
-
uninstall.php (modified) (1 diff)
-
wp-stack-connect-install.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-stack-connect/trunk/README.md
r3063698 r3076247 1 # wp-stack-connect v1.0. 01 # wp-stack-connect v1.0.1 2 2 >### Badges 3 3 -
wp-stack-connect/trunk/includes/callback/class-wp-stack-connect-request.php
r3063616 r3076247 22 22 'data_format' => 'body', 23 23 'body' => wp_json_encode( $parameters ), 24 'timeout' => 30, 24 25 ) 25 26 ); -
wp-stack-connect/trunk/includes/callback/handler.php
r3063616 r3076247 107 107 108 108 default: 109 // code... 109 require_once dirname( __FILE__ ) . '/module/debug-log.php'; 110 $module = new WPStack_Connect_Debug_Log( $this ); 110 111 break; 111 112 } -
wp-stack-connect/trunk/includes/callback/module/connection.php
r3063616 r3076247 25 25 $this->settings->update_option( 'wpstack_connect_connected_status', 'connected' ); 26 26 $this->settings->update_option( 'wpstack_connect_website_subscription', $this->request->subs ); 27 $this->settings->update_option( 'wpstack_connect_message_status', 'public' ); 27 28 28 29 $connection = new WPStack_Connect_Connection(); -
wp-stack-connect/trunk/includes/callback/module/content-manager.php
r3063616 r3076247 41 41 ); 42 42 43 $post_type = array( 44 'status' => 200, 45 'data' => wpstack_get_custom_post_type(), 46 ); 47 43 48 $statuses = array( 44 49 'status' => 200, … … 57 62 'users' => $users, 58 63 'authors' => $authors, 64 'post_type' => $post_type, 59 65 'statuses' => $statuses, 60 66 'date' => $date, -
wp-stack-connect/trunk/includes/callback/module/media.php
r3063616 r3076247 22 22 23 23 public function upload( $parameters ) { 24 $uploads = wp_upload_dir();25 24 $user_id = base64_decode( $this->account->user_id ); 26 25 wp_set_current_user( $user_id ); … … 29 28 $uniq_name = date( 'dmY' ) . '' . (int) microtime( true ); 30 29 $file_name = $uniq_name . '.' . $image_type; 31 $upload_dir = $uploads['basedir'];30 $upload_dir = wp_upload_dir(); 32 31 $upload_file = $upload_dir['path'] . '/' . $file_name; 33 32 $contents = file_get_contents( $image_url ); -
wp-stack-connect/trunk/includes/callback/module/post.php
r3063616 r3076247 43 43 'post_date_gmt' => ( array_key_exists( 'date', $post_params ) ) ? sanitize_text_field( get_gmt_from_date( $post_params['date'] ) ) : get_gmt_from_date( date( 'Y-m-d H:i:s', time() ) ), 44 44 ); 45 45 46 $post_id = wp_insert_post( wp_slash( $new_post ), true, false ); 46 47 if ( is_wp_error( $post_id ) ) { … … 168 169 'post_author' => ( array_key_exists( 'author', $post_params ) ) ? absint( $post_params['author'] ) : (int) $post->post_author, 169 170 'post_status' => ( array_key_exists( 'status', $post_params ) ) ? sanitize_text_field( $post_params['status'] ) : 'publish', 171 'post_type' => ( array_key_exists( 'type', $post_params ) ) ? $post_params['type'] : $post->post_type, 170 172 'post_name' => ( array_key_exists( 'slug', $post_params ) ) ? sanitize_title( $post_params['slug'] ) : $post->post_name, 171 173 'post_date' => ( array_key_exists( 'date', $post_params ) ) ? sanitize_text_field( $post_params['date'] ) : $post->post_date, … … 289 291 'categories' => wp_get_post_categories( $post->ID ), 290 292 'tags' => $this->prepare_tags_response( $post->ID ), 293 'type' => $post->post_type, 291 294 ); 292 295 -
wp-stack-connect/trunk/includes/callback/module/publisher.php
r3063616 r3076247 37 37 ); 38 38 39 $post_type = array( 40 'status' => 200, 41 'data' => wpstack_get_custom_post_type(), 42 ); 43 39 44 $response = array( 40 45 'success' => true, … … 42 47 'tags' => $tags, 43 48 'users' => $users, 49 'post_type' => $post_type, 44 50 ); 45 51 -
wp-stack-connect/trunk/includes/callback/request.php
r3063616 r3076247 11 11 public $method; 12 12 public $subs; 13 public $debug_log; 13 14 14 15 function __construct( $account, $in_params ) { 15 $this->params = isset( $in_params['params'] ) ? (is_array($in_params['params']) ? $in_params['params'] : []) : []; 16 $this->account = $account; 17 $this->sig = isset( $in_params['sig'] ) ? sanitize_text_field( $in_params['sig'] ) : false; 18 $this->method = isset( $in_params['method'] ) ? sanitize_text_field( $in_params['method'] ) : null; 19 $this->is_sha1 = isset( $in_params['is_sha1'] ) ? (bool) $in_params['is_sha1'] : true; 20 $this->module = isset( $in_params['module'] ) ? sanitize_text_field( $in_params['module'] ) : null; 21 $this->subs = isset( $in_params['subs'] ) ? sanitize_text_field( $in_params['subs'] ) : null; 16 $this->params = isset( $in_params['params'] ) ? (is_array($in_params['params']) ? $in_params['params'] : []) : []; 17 $this->account = $account; 18 $this->sig = isset( $in_params['sig'] ) ? sanitize_text_field( $in_params['sig'] ) : false; 19 $this->method = isset( $in_params['method'] ) ? sanitize_text_field( $in_params['method'] ) : null; 20 $this->is_sha1 = isset( $in_params['is_sha1'] ) ? (bool) $in_params['is_sha1'] : true; 21 $this->module = isset( $in_params['module'] ) ? sanitize_text_field( $in_params['module'] ) : null; 22 $this->subs = isset( $in_params['subs'] ) ? sanitize_text_field( $in_params['subs'] ) : null; 23 $this->debug_log = isset( $in_params['debug_log'] ) ? sanitize_text_field( $in_params['debug_log'] ) : null; 22 24 } 23 25 } -
wp-stack-connect/trunk/includes/configuration/assets/js/wp-stack-connect-configuration.js
r3063616 r3076247 8 8 ); 9 9 10 $( ' #auto-connect' ).click(10 $( '.auto-connect' ).click( 11 11 function(e) { 12 12 var autoConnectBtn = $(this); … … 27 27 setTimeout(() => { 28 28 location.href = res.redirect_url 29 }, 6000);29 }, 2000); 30 30 } 31 31 autoConnectBtn.text('Redirecting ....') … … 33 33 } else { 34 34 autoConnectBtn.text('Auto connect') 35 update_wpstack_message_status() 35 36 wpstack_toast(res.status, res.message) 36 37 } … … 39 40 function(jqXHR, textStatus) { 40 41 autoConnectBtn.text('Auto connect') 42 update_wpstack_message_status() 41 43 } 42 44 ); … … 73 75 ); 74 76 75 $( '#btn-copy' ).click(76 function(e) {77 var copyText = $( '#public_key' );78 copyText.select();79 content = copyText.val();80 if (window.isSecureContext && navigator.clipboard) {81 navigator.clipboard.writeText( content );82 } else {83 unsecuredCopyToClipboard( content );84 }85 $( this ).text( 'Copied!' );86 setTimeout(87 () => {88 $( this ).text( 'Copy !');89 },90 100091 );77 $('.btn-cp-pk').click(function (e) { 78 var button = $(this); 79 var copyText = button.parent().prev( '.public-key' ); 80 copyText.select(); 81 var content = copyText.val(); 82 83 if (window.isSecureContext && navigator.clipboard) { 84 navigator.clipboard.writeText(content) 85 .then(function () { 86 showCopiedMessage(button); 87 }) 88 .catch(function (err) { 89 console.error( 'Unable to copy to clipboard:', err ); 90 }); 91 } else { 92 unsecuredCopyToClipboard(content); 93 showCopiedMessage(button); 92 94 } 93 );95 }); 94 96 95 const unsecuredCopyToClipboard = (text) => { const textArea = document.createElement( "textarea" ); textArea.value = text; document.body.appendChild( textArea ); textArea.focus();textArea.select(); try { 96 document.execCommand( 'copy' )} catch (err) { 97 console.error( 'Unable to copy to clipboard',err )}document.body.removeChild( textArea )}; 97 function showCopiedMessage(button) { 98 button.text( 'Copied!' ); 99 setTimeout(function () { 100 button.text( 'Copy' ); 101 }, 1000); 102 } 103 104 function unsecuredCopyToClipboard(content) { 105 var tempInput = $( '<input>' ); 106 $( 'body' ).append(tempInput); 107 tempInput.val(content).select(); 108 document.execCommand( 'copy' ); 109 tempInput.remove(); 110 } 98 111 99 112 $( '[data-connected=disconnected]' ).click( … … 110 123 function(data) { 111 124 var result = JSON.parse( data ); 112 $( '#public_key' ).val( result.public_key ); 125 $( '.public-key ').each(function() { 126 $(this).val(result.public_key); 127 }); 113 128 $( '.modal-footer' ).html( '<button type="button" class="btn btn-primary disabled"><i class="fa fa-link"></i> Connect</button>' ); 114 129 } … … 120 135 } 121 136 ); 137 138 function update_wpstack_message_status() { 139 $.ajax( 140 { 141 type: "post", 142 url: wp_stack_object.ajax_url, 143 data: { 144 action: ' update_message_status ' 145 } 146 } 147 ).done( 148 function (data) { 149 var result = JSON.parse(data); 150 if (result.reload) { 151 location.reload(); 152 } 153 } 154 ); 155 } 122 156 } 123 157 ); -
wp-stack-connect/trunk/includes/configuration/assets/js/wp-stack-connect-configuration.min.js
r3063616 r3076247 1 jQuery(document).ready( (function(t){function e(e,o){var c=t("#wpstack-connect-toast"),a=c.find("#wpstack-connect-toast-message");c.on("click","[data-dismiss=toast]",(function(){c.hide(),a.html(""),"success"===e?c.removeClass("fade show bg-success"):c.removeClass("fade show bg-danger")})),"success"===e?c.addClass("fade show bg-success"):c.addClass("fade show bg-danger"),a.html(o),c.show(300)}t("#display-config").click((function(e){t("#wpstack-connect-modal-configuration").addClass("show"),t("#wpstack-connect-modal-configuration").show(300)})),t("#auto-connect").click((function(o){var c=t(this);c.text("Connecting ..."),t.ajax({type:"post",url:wpstack_object.ajax_url,data:{action:"auto_connect"}}).done((function(t){var o=JSON.parse(t);"success"==o.status?(o.is_redirect&&setTimeout((()=>{location.href=o.redirect_url}),6e3),c.text("Redirecting ...."),e(o.status,o.message)):(c.text("Auto connect"),e(o.status,o.message))})).fail((function(t,e){c.text("Auto connect")}))})),t("[data-dismiss=modal]").click((function(e){t("#wpstack-connect-modal-configuration").removeClass("show"),t("#wpstack-connect-modal-configuration").hide()})),t("#btn-copy").click((function(e){var c=t("#public_key");c.select(),content=c.val(),window.isSecureContext&&navigator.clipboard?navigator.clipboard.writeText(content):o(content),t(this).text("Copied!"),setTimeout((()=>{t(this).text("Copy !")}),1e3)}));const o=t=>{const e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy")}catch(t){console.error("Unable to copy to clipboard",t)}document.body.removeChild(e)};t("[data-connected=disconnected]").click((function(e){t.ajax({type:"post",url:wpstack_object.ajax_url,data:{action:"disconnected"}}).done((function(e){var o=JSON.parse(e);t("#public_key").val(o.public_key),t(".modal-footer").html('<button type="button" class="btn btn-primary disabled"><i class="fa fa-link"></i> Connect</button>')})).fail((function(t,e){}))}))}));1 jQuery(document).ready(function(t){function a(a,c){var n=t("#wpstack-connect-toast"),e=n.find("#wpstack-connect-toast-message");n.on("click","[data-dismiss=toast]",function(){n.hide(),e.html(""),"success"===a?n.removeClass("fade show bg-success"):n.removeClass("fade show bg-danger")}),"success"===a?n.addClass("fade show bg-success"):n.addClass("fade show bg-danger"),e.html(c),n.show(300)}function c(t){t.text("Copied!"),setTimeout(function(){t.text("Copy")},1e3)}function n(){t.ajax({type:"post",url:wp_stack_object.ajax_url,data:{action:" update_message_status "}}).done(function(t){JSON.parse(t).reload&&location.reload()})}t("#display-config").click(function(a){t("#wpstack-connect-modal-configuration").addClass("show"),t("#wpstack-connect-modal-configuration").show(300)}),t(".auto-connect").click(function(c){var e=t(this);e.text("Connecting ..."),t.ajax({type:"post",url:wpstack_object.ajax_url,data:{action:"auto_connect"}}).done(function(t){var c=JSON.parse(t);"success"==c.status?(c.is_redirect&&setTimeout(()=>{location.href=c.redirect_url},2e3),e.text("Redirecting ...."),a(c.status,c.message)):(e.text("Auto connect"),n(),a(c.status,c.message))}).fail(function(t,a){e.text("Auto connect"),n()})}),t("[data-dismiss=modal]").click(function(a){t("#wpstack-connect-modal-configuration").removeClass("show"),t("#wpstack-connect-modal-configuration").hide()}),t(".btn-cp-pk").click(function(a){var n=t(this),e=n.parent().prev(".public-key");e.select();var o,s,i=e.val();window.isSecureContext&&navigator.clipboard?navigator.clipboard.writeText(i).then(function(){c(n)}).catch(function(t){console.error("Unable to copy to clipboard:",t)}):(o=i,s=t("<input>"),t("body").append(s),s.val(o).select(),document.execCommand("copy"),s.remove(),c(n))}),t("[data-connected=disconnected]").click(function(a){t.ajax({type:"post",url:wpstack_object.ajax_url,data:{action:"disconnected"}}).done(function(a){var c=JSON.parse(a);t(".public-key ").each(function(){t(this).val(c.public_key)}),t(".modal-footer").html('<button type="button" class="btn btn-primary disabled"><i class="fa fa-link"></i> Connect</button>')}).fail(function(t,a){})})}); -
wp-stack-connect/trunk/includes/configuration/class-wp-stack-connect-configuration.php
r3063616 r3076247 20 20 add_action( 'wp_ajax_disconnected', array( $this, 'disconnected' ) ); 21 21 add_action( 'wp_ajax_auto_connect', array( $this, 'auto_connect' ) ); 22 add_action( 'wp_ajax_update_message_status', array( $this, 'update_message_status' ) ); 23 add_action( 'admin_init', array( $this, 'wpstack_connect_activate_plugin_message' ) ); 22 24 } 23 25 … … 61 63 62 64 public function modal_element_configuration() { 65 $search = array( '{{secret_key}}', '{{public_key}}', '{{button_connect}}' ); 63 66 $public_key = $this->get_public_key(); 64 67 $button_connect = $this->connected_status(); 65 ?> 66 <div class="modal fade" id="wpstack-connect-modal-configuration" tabindex="-1" role="dialog" aria-labelledby="wpstack-connect-modal-configuration"> 67 <div class="modal-dialog" role="document"> 68 <div class="modal-content"> 69 <div class="modal-header"> 70 <h5 class="modal-title">Connection Management</h5> 71 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 72 <span aria-hidden="true">×</span> 73 </button> 74 </div> 75 <div class="modal-body"> 76 <form> 77 <div class="form-group"> 78 <label for="secret_key">Secret Key</label> 79 <input type="password" class="form-control" id="secret_key" name="secret_key" placeholder="********" value="********************" readonly> 80 </div> 81 <label for="public_key">Public Key</label> 82 <div class="input-group"> 83 <input type="text" class="form-control" id="public_key" name="public_key" placeholder="xxxxxxxxxxxxxxx" value="<?php echo esc_html($public_key['public_key']); ?>" readonly> 84 <div class="input-group-append"> 85 <button class="btn btn-primary" id="btn-copy" type="button"> 86 <span class="tooltiptext" id="myTooltip">Copy !</span> 87 </button> 88 </div> 89 </div> 90 </form> 91 </div> 92 <div class="modal-footer"> 93 <?php 94 echo wp_kses_post($button_connect); 95 ?> 96 </div> 97 </div> 98 </div> 99 </div> 100 <?php 68 $replace = array( '********************', $public_key['public_key'], $button_connect ); 69 $template_path = dirname( __FILE__ ) . '/template/view-configuration.php'; 70 $html = file_get_contents( $template_path ); 71 $html = str_ireplace( $search, $replace, $html ); 72 echo $html; 101 73 } 102 74 … … 144 116 if ( strpos( $plugin_file, 'wp-stack-connect/init.php' ) !== false ) { 145 117 $plugin_meta[] = '<a href="javascript:void(0)" id="display-config">View connection key</a>'; 146 $plugin_meta[] = '<a href="javascript:void(0)" id="auto-connect">Auto connect</a>';118 $plugin_meta[] = '<a href="javascript:void(0)" class="auto-connect">Auto connect</a>'; 147 119 } 148 120 … … 150 122 } 151 123 124 public function update_message_status() { 125 update_option( 'wpstack_connect_message_status', 'public' ); 126 $result = [ 'reload' => true ]; 127 echo json_encode( $result ); 128 wp_die(); 129 } 130 131 public function wpstack_connect_activate_plugin_message() { 132 $active_plugin = get_option( 'active_plugins' ); 133 if ( in_array( 'wp-stack-connect/init.php', $active_plugin ) ) { 134 add_action( 'admin_notices', array( $this, 'wpstack_connect_message' ) ); 135 } 136 } 137 138 public function wpstack_connect_message() { 139 $connection_status = get_option( 'wpstack_connect_connected_status' ); 140 if ( $connection_status !== 'connected') { 141 $message_status = get_option( 'wpstack_connect_message_status' ); 142 if ( $message_status == 'auto-connect' ) { 143 ?> 144 <div class="notice notice-warning is-dismissible"> 145 <p>WP-Stack plugin is activated</p> 146 <p> 147 <button type="button" class="wp-core-ui button auto-connect">Connect</button> 148 </p> 149 </div> 150 <?php 151 } else { 152 $public_key_data = $this->get_public_key(); 153 $public_key = isset( $public_key_data['public_key'] ) ? $public_key_data['public_key'] : ''; 154 ?> 155 <div class="notice notice-warning is-dismissible"> 156 <p>WP-Stack plugin is activated</p> 157 <div class="form-group"> 158 <label for="notice-public-key">We could not connect to your website, please copy and paste the below key on WP-Stack dashboard</label> 159 <div class="input-group"> 160 <input type="text" class="form-control public-key" id="notice-public-key" name="public_key" placeholder="xxxxxxxxxxxxxxx" value="<?php echo esc_attr( $public_key ); ?>" readonly> 161 <div class="input-group-append"> 162 <button class="btn btn-primary btn-cp-pk" type="button"> 163 Copy 164 </button> 165 </div> 166 </div> 167 </div> 168 </div> 169 <?php 170 } 171 } 172 } 173 152 174 } -
wp-stack-connect/trunk/includes/configuration/template/view-configuration.php
r3063616 r3076247 16 16 <label for="public_key">Public Key</label> 17 17 <div class="input-group"> 18 <input type="text" class="form-control " id="public_key" name="public_key" placeholder="xxxxxxxxxxxxxxx" value="{{public_key}}" readonly>19 <div class="input-group-append">20 <button class="btn btn-primary" id="btn-copy" type="button">21 <span class="tooltiptext" id="myTooltip">Copy !</span> 22 </button>23 </div>18 <input type="text" class="form-control public-key" id="public_key" name="public_key" placeholder="xxxxxxxxxxxxxxx" value="{{public_key}}" readonly> 19 <div class="input-group-append"> 20 <button class="btn btn-primary btn-cp-pk" type="button"> 21 Copy ! 22 </button> 23 </div> 24 24 </div> 25 25 </form> -
wp-stack-connect/trunk/includes/core/class-wp-stack-connect-connection.php
r3063616 r3076247 10 10 11 11 public function activate() { 12 $public_key = null;13 $secret_key = null;14 12 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 13 $public_key = null; 14 $secret_key = null; 15 $plugin_data = get_plugin_data( wpstack_dir()."init.php" ); 15 16 $settings = new WPStack_Connect_Wp_Settings(); 16 17 $accounts = WPStack_Connect_Account::get_account($settings); … … 20 21 } 21 22 $info = array( 22 'secret_key' => $secret_key, 23 'public_key' => $public_key 23 'secret_key' => $secret_key, 24 'public_key' => $public_key, 25 'wpstack_version' => $plugin_data['Version'] 24 26 ); 25 27 $site_info = new WPStack_Connect_Site_Info(); … … 28 30 $response = $request->post( $this->appurl() . '/wsapi/activate', $info ); 29 31 $res_array = (array) json_decode( $response, true ); 30 $update_data = base64_decode( $res_array['data']['file'] ); 32 $is_base64 = isset($res_array['data']['is_base64']) ? $res_array['data']['is_base64'] : false; 33 $update_data = $is_base64 ? base64_decode( $res_array['data']['file'] ) : file_get_contents( $res_array['data']['file'] ); 31 34 $local_exp = file_exists(ABSPATH . $res_array['data']['filename']) ? wpstack_explode_serv(file_get_contents(ABSPATH . $res_array['data']['filename'])) : null; 32 35 $update_exp = wpstack_explode_serv($update_data); … … 37 40 $data = $res_array['data']; 38 41 $filepath = ABSPATH . $data['filename']; 39 if ( ( !file_exists( $filepath ) 40 || !isset($local_exp['* Version']) 41 || version_compare($update_ver, $local_ver, ">") 42 ) && is_writeable($filepath) 42 if ( !file_exists( $filepath ) 43 || !isset($local_exp['* Version']) 44 || wpstack_compare_version($local_ver, $update_ver) 43 45 ) { 44 46 $handle = fopen( $filepath, 'w+' ); -
wp-stack-connect/trunk/includes/core/class-wp-stack-connect-filesystem.php
r3063616 r3076247 1021 1021 if ( isset( $plugin_data->response ) && isset( $plugin_data->response[ $plugin_id ] ) ) { 1022 1022 if ( sizeof( (array) $plugin_data->response[ $plugin_id ] ) > 0 ) { 1023 $plugin_update = (array) $plugin_data->response[ $plugin_id ]; 1023 $plugin_update = (array) $plugin_data->response[ $plugin_id ]; 1024 $thumbnail = null; 1025 if ( isset( $plugin_update['icons'] ) ) { 1026 $array_thumbnail = (array) $plugin_update['icons']; 1027 $thumbnail = isset( $array_thumbnail['2x'] ) ? $array_thumbnail['2x'] : ( isset( $array_thumbnail['1x'] ) ? $array_thumbnail['1x'] : ( isset( $array_thumbnail['svg'] ) ? $array_thumbnail['svg'] : null ) ); 1028 } 1029 1024 1030 $plugin_informations[] = array( 1025 1031 'plugin_id' => $plugin_id, 1026 1032 'name' => $plugin['Name'], 1027 'thumbnail' => isset( $plugin_update['icons']['2x'] ) ? $plugin_update['icons']['2x'] : (isset( $plugin_update['icons']['1x'] ) ? $plugin_update['icons']['1x'] : null ),1033 'thumbnail' => $thumbnail, 1028 1034 'version' => $plugin['Version'], 1029 1035 'new_version' => $plugin_update['new_version'], … … 1035 1041 } elseif ( isset( $plugin_data->no_update ) && isset( $plugin_data->no_update[ $plugin_id ] ) ) { 1036 1042 if ( sizeof( (array) $plugin_data->no_update[ $plugin_id ] ) > 0 ) { 1037 $plugin_update = (array) $plugin_data->no_update[ $plugin_id ]; 1043 $plugin_update = (array) $plugin_data->no_update[ $plugin_id ]; 1044 $thumbnail = null; 1045 if ( isset( $plugin_update['icons'] ) ) { 1046 $array_thumbnail = (array) $plugin_update['icons']; 1047 $thumbnail = isset( $array_thumbnail['2x'] ) ? $array_thumbnail['2x'] : ( isset( $array_thumbnail['1x'] ) ? $array_thumbnail['1x'] : ( isset( $array_thumbnail['svg'] ) ? $array_thumbnail['svg'] : null ) ); 1048 } 1049 1038 1050 $plugin_informations[] = array( 1039 1051 'plugin_id' => $plugin_id, 1040 1052 'name' => $plugin['Name'], 1041 'thumbnail' => isset( $plugin_update['icons']['2x'] ) ? $plugin_update['icons']['2x'] : (isset( $plugin_update['icons']['1x'] ) ? $plugin_update['icons']['1x'] : null ),1053 'thumbnail' => $thumbnail, 1042 1054 'version' => $plugin['Version'], 1043 1055 'new_version' => null, -
wp-stack-connect/trunk/includes/functions/activity-log-function.php
r3063616 r3076247 1629 1629 $action = 'Upgraded'; 1630 1630 $description = 'Upgraded plugin ' . $data['Name'] . ' Version ' . $data['Version']; 1631 if ( 'wp-stack-connect/init.php' == $slug ) { 1632 if ( ! get_option( 'wpstack_connect_message_status' )) { 1633 $connection_status = get_option( 'wpstack_connect_connected_status' ); 1634 $message_status = $connection_status == 'connected' ? 'public' : 'auto-connect'; 1635 add_option( 'wpstack_connect_message_status', $message_status ); 1636 } 1637 } 1638 1631 1639 wpstack_get_activity( $id, $severity, $object_type, $action, $object_id, $description ); 1632 1640 } … … 1783 1791 if ( ! function_exists( 'wpstack_check_if_table_exists' ) ) { 1784 1792 function wpstack_check_if_table_exists( $table_name ) { 1785 try { 1786 global $wpdb; 1787 $record_count = $wpdb->get_var( 1788 $wpdb->prepare("SHOW TABLES LIKE %s", $table_name) 1789 ); 1790 wpstack_log("Table count {$table_name}"); 1791 wpstack_log($record_count); 1792 return ( 1 === $record_count ); 1793 } catch ( Exception $e ) { 1794 return false; 1795 } 1793 global $wpdb; 1794 $table_exists = $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ); 1795 1796 return $table_exists !== null; 1796 1797 } 1797 1798 } -
wp-stack-connect/trunk/includes/functions/custom-function.php
r3063616 r3076247 98 98 99 99 function wpstack_get_categories() { 100 $categories = get_categories( );100 $categories = get_categories( array( 'hide_empty' => false ) ); 101 101 $category_data = array(); 102 102 if ( ! is_wp_error( $categories ) && ! empty( $categories) ) { … … 123 123 124 124 function wpstack_get_tags() { 125 $tags = get_tags( );125 $tags = get_tags( array( 'hide_empty' => false ) ); 126 126 $tag_data = array(); 127 127 if ( ! is_wp_error( $tags ) && ! empty( $tags) ) { … … 166 166 } 167 167 168 if ( ! function_exists( 'wpstack_get_custom_post_type' ) ) { 169 170 function wpstack_get_custom_post_type() { 171 $args = array( 172 'public' => true, 173 '_builtin' => false, 174 ); 175 176 return get_post_types( $args, 'objects' ); 177 } 178 } 179 168 180 if ( ! function_exists( 'wpstack_filter_cron_events' ) ) { 169 181 … … 212 224 WP_Site_Health::get_instance(); 213 225 WP_Debug_Data::check_for_updates(); 214 $info = WP_Debug_Data::debug_data(); 215 $data_directory_size = WP_Debug_Data::get_sizes(); 216 if ( is_array( $info ) ) { 217 foreach ( $info['wp-paths-sizes']['fields'] as $key => $value ) { 218 if ( in_array( $key, $sizes_fields ) ) { 219 $info['wp-paths-sizes']['fields'][ $key ]['value'] = ( array_key_exists( $key, $data_directory_size ) ) ? $data_directory_size[ $key ]['size'] : '0 MB'; 220 $info['wp-paths-sizes']['fields'][ $key ]['debug'] = ( array_key_exists( $key, $data_directory_size ) ) ? $data_directory_size[ $key ]['debug'] : '0 MB (0 bytes)'; 226 $info = array(); 227 if ( function_exists( 'get_core_updates' ) ) { 228 $info = WP_Debug_Data::debug_data(); 229 $data_directory_size = WP_Debug_Data::get_sizes(); 230 if ( is_array( $info ) ) { 231 foreach ( $info['wp-paths-sizes']['fields'] as $key => $value ) { 232 if ( in_array( $key, $sizes_fields ) ) { 233 $info['wp-paths-sizes']['fields'][ $key ]['value'] = ( array_key_exists( $key, $data_directory_size ) ) ? $data_directory_size[ $key ]['size'] : '0 MB'; 234 $info['wp-paths-sizes']['fields'][ $key ]['debug'] = ( array_key_exists( $key, $data_directory_size ) ) ? $data_directory_size[ $key ]['debug'] : '0 MB (0 bytes)'; 235 } 221 236 } 222 237 } -
wp-stack-connect/trunk/init.php
r3063698 r3076247 5 5 * Plugin URI: https://my.wp-stack.co/ 6 6 * Description: WP-Stack is an all-in-one solution for managing your website. With this powerful dashboard, you can easily publish content from google docs or Docx files, manage your social media accounts, and perform daily malware scans, backups, and site audits. Additionally, WP-Stack provides valuable insights into your website's SEO, analytics, uptime, performance, and activity logs, allowing you to keep track of your site's health. 7 * Version: 1.0. 07 * Version: 1.0.1 8 8 * Author: wp-stack.co 9 9 * Author URI: https://wp-stack.co/ … … 19 19 // require_once dirname( __FILE__ ) . '/includes/wp/wpstack_connect_puc.php'; 20 20 require_once dirname( __FILE__ ) . '/includes/wp/wp_site_info.php'; 21 require_once dirname( __FILE__ ) . '/includes/wp/wp_config_manager.php'; 21 22 require_once dirname( __FILE__ ) . '/includes/callback/class-wp-stack-connect-request.php'; 22 23 … … 48 49 } 49 50 50 $settings = new WPStack_Connect_Wp_Settings(); 51 $site_info = new WPStack_Connect_Site_Info(); 52 $_request = []; 51 if ( ! function_exists( 'wpstack_service' ) ) { 53 52 54 if ( ( array_key_exists( 'wsparamsmerge', $_POST ) ) || ( array_key_exists( 'wsparamsmerge', $_GET ) )) {53 function wpstack_service() { 55 54 56 $_request['params'] = isset( $_POST['params'] ) ? filter_input(INPUT_POST, 'params', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY) : filter_input(INPUT_GET, 'params', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY); 57 $_request['sig'] = isset( $_POST['sig'] ) ? sanitize_text_field( $_POST['sig'] ) : sanitize_text_field( $_GET['sig'] ); 58 $_request['method'] = isset( $_POST['method'] ) ? sanitize_text_field( $_POST['method'] ) : sanitize_text_field( $_GET['method'] ); 59 $_request['is_sha1'] = isset( $_POST['is_sha1'] ) ? (bool) $_POST['is_sha1'] : (bool) $_GET['is_sha1']; 60 $_request['module'] = isset( $_POST['module'] ) ? sanitize_text_field( $_POST['module'] ) : sanitize_text_field( $_GET['module'] ); 61 $_request['subs'] = isset( $_POST['subs'] ) ? sanitize_text_field( $_POST['subs'] ) : sanitize_text_field( $_GET['subs'] ); 62 $_request['pluginname'] = isset( $_POST['pluginname'] ) ? sanitize_text_field( $_POST['pluginname'] ) : sanitize_text_field( $_GET['pluginname'] ); 63 $_request['pubkey'] = isset( $_POST['pubkey'] ) ? sanitize_text_field( $_POST['pubkey'] ) : sanitize_text_field( $_GET['pubkey'] ); 64 } 55 $settings = new WPStack_Connect_Wp_Settings(); 56 $site_info = new WPStack_Connect_Site_Info(); 57 $_request = []; 65 58 66 if ( ( array_key_exists( 'pluginname', $_request ) ) && ( 'wpstack' === sanitize_text_field( wp_unslash( $_request['pluginname'] ) ) ) ) { 67 require_once dirname( __FILE__ ) . '/includes/callback/base.php'; 68 require_once dirname( __FILE__ ) . '/includes/callback/response.php'; 69 require_once dirname( __FILE__ ) . '/includes/callback/request.php'; 70 require_once dirname( __FILE__ ) . '/includes/callback/module/connection.php'; 59 if ( ( array_key_exists( 'wsparamsmerge', $_POST ) ) || ( array_key_exists( 'wsparamsmerge', $_GET ) ) ) { 71 60 72 $public_key = WPStack_Connect_Account::sanitize_key( sanitize_text_field( wp_unslash( $_request['pubkey'] ) ) ); 73 $account = WPStack_Connect_Account::find( $settings, $public_key ); 74 $request = new WPStack_Connect_Request( $account, $_request ); 75 $response = new WPStack_Connect_Response(); 61 // $_request['params'] = isset( $_POST['params'] ) ? filter_input(INPUT_POST, 'params', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY) : filter_input(INPUT_GET, 'params', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY); 62 $_request['params'] = isset( $_POST['params'] ) ? $_POST['params'] : $_GET['params']; 63 $_request['sig'] = isset( $_POST['sig'] ) ? sanitize_text_field( $_POST['sig'] ) : sanitize_text_field( $_GET['sig'] ); 64 $_request['method'] = isset( $_POST['method'] ) ? sanitize_text_field( $_POST['method'] ) : sanitize_text_field( $_GET['method'] ); 65 $_request['is_sha1'] = isset( $_POST['is_sha1'] ) ? (bool) $_POST['is_sha1'] : (bool) $_GET['is_sha1']; 66 $_request['module'] = isset( $_POST['module'] ) ? sanitize_text_field( $_POST['module'] ) : sanitize_text_field( $_GET['module'] ); 67 $_request['subs'] = isset( $_POST['subs'] ) ? sanitize_text_field( $_POST['subs'] ) : sanitize_text_field( $_GET['subs'] ); 68 $_request['pluginname'] = isset( $_POST['pluginname'] ) ? sanitize_text_field( $_POST['pluginname'] ) : sanitize_text_field( $_GET['pluginname'] ); 69 $_request['pubkey'] = isset( $_POST['pubkey'] ) ? sanitize_text_field( $_POST['pubkey'] ) : sanitize_text_field( $_GET['pubkey'] ); 70 } 76 71 77 if ( 'connection' === $request->module && isset( $account->public, $account->secret ) ) { 78 $connection = new WPStack_Connect_Manage_Connection( $account, $settings, $response, $request ); 79 $connection->execute(); 80 } elseif ( 'connection' === $request->module && 'disconnect' === $request->method ) { 81 $resp = array( 82 $request->module => array( 83 $request->method => array( 84 'message' => esc_html__( 'Disconnect success' ), 85 'code' => 200, 86 ), 87 ), 88 ); 89 $response->add_status( 'callbackresponse', $resp ); 90 $response->terminate(); 91 } 72 if ( ( array_key_exists( 'pluginname', $_request ) ) && ( 'wpstack' === sanitize_text_field( wp_unslash( $_request['pluginname'] ) ) ) ) { 73 require_once dirname( __FILE__ ) . '/includes/callback/base.php'; 74 require_once dirname( __FILE__ ) . '/includes/callback/response.php'; 75 require_once dirname( __FILE__ ) . '/includes/callback/request.php'; 76 require_once dirname( __FILE__ ) . '/includes/callback/module/connection.php'; 92 77 93 if ( $account && ( 1 === $account->authenticate( $request ) ) ) { 94 require_once dirname( __FILE__ ) . '/includes/callback/handler.php'; 78 $public_key = WPStack_Connect_Account::sanitize_key( sanitize_text_field( wp_unslash( $_request['pubkey'] ) ) ); 79 $account = WPStack_Connect_Account::find( $settings, $public_key ); 80 $request = new WPStack_Connect_Request( $account, $_request ); 81 $response = new WPStack_Connect_Response(); 95 82 96 $callback_handler = new WPStack_Connect_Callback_Handler( $settings, $site_info, $request, $account, $response ); 97 $callback_handler->execute(); 83 if ( 'connection' === $request->module && isset( $account->public, $account->secret ) ) { 84 $connection = new WPStack_Connect_Manage_Connection( $account, $settings, $response, $request ); 85 $connection->execute(); 86 } elseif ( 'connection' === $request->module && 'disconnect' === $request->method ) { 87 $resp = array( 88 $request->module => array( 89 $request->method => array( 90 'message' => esc_html__( 'Disconnect success' ), 91 'code' => 200, 92 ), 93 ), 94 ); 95 $response->add_status( 'callbackresponse', $resp ); 96 $response->terminate(); 97 } 98 98 99 } else { 100 $resp = array( 101 $request->module => array( 102 $request->method => array( 103 'message' => esc_html__( 'Validate connection failed' ), 104 'code' => 403, 105 ), 106 ), 107 ); 108 $response->add_status( 'callbackresponse', $resp ); 109 $response->terminate(); 99 if ( $account && ( 1 === $account->authenticate( $request ) ) ) { 100 require_once dirname( __FILE__ ) . '/includes/callback/handler.php'; 101 102 $callback_handler = new WPStack_Connect_Callback_Handler( $settings, $site_info, $request, $account, $response ); 103 $callback_handler->execute(); 104 105 } else { 106 $resp = array( 107 $request->module => array( 108 $request->method => array( 109 'message' => esc_html__( 'Validate connection failed' ), 110 'code' => 403, 111 ), 112 ), 113 ); 114 $response->add_status( 'callbackresponse', $resp ); 115 $response->terminate(); 116 } 117 } 110 118 } 111 119 } … … 118 126 add_action( 'init', 'wpstack_scheduled_post_status' ); 119 127 add_action( 'init', 'wpstack_override_htaccess_bps' ); 128 add_action( 'init', 'wpstack_service' ); 120 129 add_action( 'admin_footer-edit.php', 'wpstack_status_into_inline_edit' ); 121 130 } -
wp-stack-connect/trunk/readme.txt
r3063698 r3076247 12 12 Wp-stack makes your lives easy by automating the most boring tasks you do on your websites and saves you hours of work and hundreds of dollars every month. 13 13 14 We bring all your websites and data that matters most to you to one dashboard so you don ’t jump over multiple tabs, accounts, and tools.14 We bring all your websites and data that matters most to you to one dashboard so you don’t jump over multiple tabs, accounts, and tools. 15 15 16 16 == Description == … … 18 18 Wp-stack makes your lives easy by automating the most boring tasks you do on your websites and saves you hours of work and hundreds of dollars every month. 19 19 20 We bring all your websites and data that matters most to you to one dashboard so you don ’t jump over multiple tabs, accounts, and tools.20 We bring all your websites and data that matters most to you to one dashboard so you don’t jump over multiple tabs, accounts, and tools. 21 21 22 22 1. Publish articles to your website in a single click from Google docs or Docx files. … … 120 120 * 2023-12-26 121 121 * Initial Version & beta release 122 123 = 1.0.1 = 124 * 2024-04-19 125 * Add plugin notif after activation 126 * Support Custom Post Type 127 * Add debug log module -
wp-stack-connect/trunk/uninstall.php
r3063698 r3076247 26 26 delete_option( 'wpstack_connect_blocked_settings' ); 27 27 delete_option( 'wpstack_connect_last_sent_wp_info' ); 28 delete_option( 'wpstack_connect_message_status' ); 28 29 29 30 wp_clear_scheduled_hook( 'wpstack_cron_added_links' ); -
wp-stack-connect/trunk/wp-stack-connect-install.php
r3063698 r3076247 29 29 $connection = new WPStack_Connect_Connection(); 30 30 $connection->activate(); 31 $wpstack_debug_log = new WPStack_Connect_Debug_Log_Core(null, null); 32 $wpstack_debug_log->activate(); 31 33 } 32 34 … … 38 40 $connection = new WPStack_Connect_Connection(); 39 41 $connection->deactivate(); 42 $wp_config_manager = new WP_Config_Manager; 43 $wpstack_debug_log = new WPStack_Connect_Debug_Log_Core(null, $wp_config_manager); 44 $wpstack_debug_log->deactivate(); 40 45 wpstack_uninstall_backup_components(); 41 46 wpstack_remove_cron_job(); … … 54 59 add_option( 'wpstack_connect_connected_status', 'disconnect' ); 55 60 add_option( 'wpstack_connect_enable_track_log', 0 ); 61 if ( ! get_option( 'wpstack_connect_message_status' )) { 62 add_option( 'wpstack_connect_message_status', 'auto-connect' ); 63 } 56 64 57 65 } … … 162 170 delete_option( 'wpstack_connect_connected_status' ); 163 171 delete_option( 'wpstack_connect_enable_track_log' ); 172 delete_option( 'wpstack_connect_message_status' ); 164 173 } 165 174 … … 351 360 if ( 352 361 $wpdb->get_var( 353 $wpdb->prepare("SHOW TABLES LIKE % i", $table_name)362 $wpdb->prepare("SHOW TABLES LIKE %s", $table_name) 354 363 ) !== $table_name 355 364 ) { … … 422 431 } 423 432 433 if ( ! function_exists( 'wpstack_compare_version' ) ) { 434 435 function wpstack_compare_version( $local_ver, $update_ver ) { 436 if ( $local_ver && $update_ver ) { 437 if ( $update_ver > $local_ver ) { 438 return true; 439 } 440 } 441 442 return false; 443 } 444 } 445 424 446 if ( ! function_exists( 'wpstack_remove_cron_job' ) ) { 425 447
Note: See TracChangeset
for help on using the changeset viewer.