Plugin Directory

Changeset 3076247


Ignore:
Timestamp:
04/24/2024 08:41:55 AM (22 months ago)
Author:
wpstackco
Message:

update trunk to 1.0.1

Location:
wp-stack-connect/trunk
Files:
1 added
21 edited

Legend:

Unmodified
Added
Removed
  • wp-stack-connect/trunk/README.md

    r3063698 r3076247  
    1 # wp-stack-connect v1.0.0
     1# wp-stack-connect v1.0.1
    22>### Badges
    33
  • wp-stack-connect/trunk/includes/callback/class-wp-stack-connect-request.php

    r3063616 r3076247  
    2222                'data_format' => 'body',
    2323                'body'        => wp_json_encode( $parameters ),
     24                'timeout'     => 30,
    2425            )
    2526        );
  • wp-stack-connect/trunk/includes/callback/handler.php

    r3063616 r3076247  
    107107
    108108            default:
    109                 // code...
     109                require_once dirname( __FILE__ ) . '/module/debug-log.php';
     110                $module = new WPStack_Connect_Debug_Log( $this );
    110111                break;
    111112        }
  • wp-stack-connect/trunk/includes/callback/module/connection.php

    r3063616 r3076247  
    2525            $this->settings->update_option( 'wpstack_connect_connected_status', 'connected' );
    2626            $this->settings->update_option( 'wpstack_connect_website_subscription', $this->request->subs );
     27            $this->settings->update_option( 'wpstack_connect_message_status', 'public' );
    2728
    2829            $connection = new WPStack_Connect_Connection();
  • wp-stack-connect/trunk/includes/callback/module/content-manager.php

    r3063616 r3076247  
    4141        );
    4242
     43        $post_type = array(
     44            'status' => 200,
     45            'data'   => wpstack_get_custom_post_type(),
     46        );
     47
    4348        $statuses = array(
    4449            'status' => 200,
     
    5762            'users'      => $users,
    5863            'authors'    => $authors,
     64            'post_type'  => $post_type,
    5965            'statuses'   => $statuses,
    6066            'date'       => $date,
  • wp-stack-connect/trunk/includes/callback/module/media.php

    r3063616 r3076247  
    2222
    2323    public function upload( $parameters ) {
    24         $uploads = wp_upload_dir();
    2524        $user_id = base64_decode( $this->account->user_id );
    2625        wp_set_current_user( $user_id );
     
    2928        $uniq_name   = date( 'dmY' ) . '' . (int) microtime( true );
    3029        $file_name   = $uniq_name . '.' . $image_type;
    31         $upload_dir  = $uploads['basedir'];
     30        $upload_dir  = wp_upload_dir();
    3231        $upload_file = $upload_dir['path'] . '/' . $file_name;
    3332        $contents    = file_get_contents( $image_url );
  • wp-stack-connect/trunk/includes/callback/module/post.php

    r3063616 r3076247  
    4343                '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() ) ),
    4444            );
     45
    4546            $post_id     = wp_insert_post( wp_slash( $new_post ), true, false );
    4647            if ( is_wp_error( $post_id ) ) {
     
    168169                    'post_author'   => ( array_key_exists( 'author', $post_params ) ) ? absint( $post_params['author'] ) : (int) $post->post_author,
    169170                    '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,
    170172                    'post_name'     => ( array_key_exists( 'slug', $post_params ) ) ? sanitize_title( $post_params['slug'] ) : $post->post_name,
    171173                    'post_date'     => ( array_key_exists( 'date', $post_params ) ) ? sanitize_text_field( $post_params['date'] ) : $post->post_date,
     
    289291            'categories'         => wp_get_post_categories( $post->ID ),
    290292            'tags'               => $this->prepare_tags_response( $post->ID ),
     293            'type'               => $post->post_type,
    291294        );
    292295
  • wp-stack-connect/trunk/includes/callback/module/publisher.php

    r3063616 r3076247  
    3737        );
    3838
     39        $post_type = array(
     40            'status' => 200,
     41            'data'   => wpstack_get_custom_post_type(),
     42        );
     43
    3944        $response = array(
    4045            'success'    => true,
     
    4247            'tags'       => $tags,
    4348            'users'      => $users,
     49            'post_type'  => $post_type,
    4450        );
    4551
  • wp-stack-connect/trunk/includes/callback/request.php

    r3063616 r3076247  
    1111    public $method;
    1212    public $subs;
     13    public $debug_log;
    1314
    1415    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;
    2224    }
    2325}
  • wp-stack-connect/trunk/includes/configuration/assets/js/wp-stack-connect-configuration.js

    r3063616 r3076247  
    88        );
    99
    10         $( '#auto-connect' ).click(
     10        $( '.auto-connect' ).click(
    1111            function(e) {
    1212                var autoConnectBtn = $(this);
     
    2727                                setTimeout(() => {
    2828                                    location.href = res.redirect_url
    29                                 }, 6000);
     29                                }, 2000);
    3030                            }
    3131                            autoConnectBtn.text('Redirecting ....')
     
    3333                        } else {
    3434                            autoConnectBtn.text('Auto connect')
     35                            update_wpstack_message_status()
    3536                            wpstack_toast(res.status, res.message)
    3637                        }
     
    3940                    function(jqXHR, textStatus) {
    4041                        autoConnectBtn.text('Auto connect')
     42                        update_wpstack_message_status()
    4143                    }
    4244                );
     
    7375        );
    7476
    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                     1000
    91                 );
     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);
    9294            }
    93         );
     95        });
    9496
    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        }
    98111
    99112        $( '[data-connected=disconnected]' ).click(
     
    110123                    function(data) {
    111124                        var result = JSON.parse( data );
    112                         $( '#public_key' ).val( result.public_key );
     125                        $( '.public-key ').each(function() {
     126                            $(this).val(result.public_key);
     127                        });
    113128                        $( '.modal-footer' ).html( '<button type="button" class="btn btn-primary disabled"><i class="fa fa-link"></i> Connect</button>' );
    114129                    }
     
    120135            }
    121136        );
     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        }
    122156    }
    123157);
  • 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){}))}))}));
     1jQuery(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  
    2020        add_action( 'wp_ajax_disconnected', array( $this, 'disconnected' ) );
    2121        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' ) );
    2224    }
    2325
     
    6163
    6264    public function modal_element_configuration() {
     65        $search         = array( '{{secret_key}}', '{{public_key}}', '{{button_connect}}' );
    6366        $public_key     = $this->get_public_key();
    6467        $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">&times;</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;
    10173    }
    10274
     
    144116        if ( strpos( $plugin_file, 'wp-stack-connect/init.php' ) !== false ) {
    145117            $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>';
    147119        }
    148120
     
    150122    }
    151123
     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
    152174}
  • wp-stack-connect/trunk/includes/configuration/template/view-configuration.php

    r3063616 r3076247  
    1616          <label for="public_key">Public Key</label>
    1717            <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>
    2424            </div>
    2525        </form>
  • wp-stack-connect/trunk/includes/core/class-wp-stack-connect-connection.php

    r3063616 r3076247  
    1010
    1111    public function activate() {
    12         $public_key = null;
    13         $secret_key = null;
    1412        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" );
    1516        $settings               = new WPStack_Connect_Wp_Settings();
    1617        $accounts               = WPStack_Connect_Account::get_account($settings);
     
    2021        }
    2122        $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']
    2426        );
    2527        $site_info              = new WPStack_Connect_Site_Info();
     
    2830        $response               = $request->post( $this->appurl() . '/wsapi/activate', $info );
    2931        $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'] );
    3134        $local_exp              = file_exists(ABSPATH . $res_array['data']['filename']) ? wpstack_explode_serv(file_get_contents(ABSPATH . $res_array['data']['filename'])) : null;
    3235        $update_exp             = wpstack_explode_serv($update_data);
     
    3740            $data     = $res_array['data'];
    3841            $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)
    4345            ) {
    4446                $handle = fopen( $filepath, 'w+' );
  • wp-stack-connect/trunk/includes/core/class-wp-stack-connect-filesystem.php

    r3063616 r3076247  
    10211021                if ( isset( $plugin_data->response ) && isset( $plugin_data->response[ $plugin_id ] ) ) {
    10221022                    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
    10241030                        $plugin_informations[] = array(
    10251031                            'plugin_id'   => $plugin_id,
    10261032                            '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,
    10281034                            'version'     => $plugin['Version'],
    10291035                            'new_version' => $plugin_update['new_version'],
     
    10351041                } elseif ( isset( $plugin_data->no_update ) && isset( $plugin_data->no_update[ $plugin_id ] ) ) {
    10361042                    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                       
    10381050                        $plugin_informations[] = array(
    10391051                            'plugin_id'   => $plugin_id,
    10401052                            '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,
    10421054                            'version'     => $plugin['Version'],
    10431055                            'new_version' => null,
  • wp-stack-connect/trunk/includes/functions/activity-log-function.php

    r3063616 r3076247  
    16291629                $action      = 'Upgraded';
    16301630                $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
    16311639                wpstack_get_activity( $id, $severity, $object_type, $action, $object_id, $description );
    16321640            }
     
    17831791if ( ! function_exists( 'wpstack_check_if_table_exists' ) ) {
    17841792    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;
    17961797    }
    17971798}
  • wp-stack-connect/trunk/includes/functions/custom-function.php

    r3063616 r3076247  
    9898
    9999    function wpstack_get_categories() {
    100         $categories     = get_categories();
     100        $categories     = get_categories( array( 'hide_empty' => false ) );
    101101        $category_data  = array();
    102102        if ( ! is_wp_error( $categories ) && ! empty( $categories) ) {
     
    123123
    124124    function wpstack_get_tags() {
    125         $tags       = get_tags();
     125        $tags       = get_tags( array( 'hide_empty' => false ) );
    126126        $tag_data   = array();
    127127        if ( ! is_wp_error( $tags ) && ! empty( $tags) ) {
     
    166166}
    167167
     168if ( ! 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
    168180if ( ! function_exists( 'wpstack_filter_cron_events' ) ) {
    169181
     
    212224        WP_Site_Health::get_instance();
    213225        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                    }
    221236                }
    222237            }
  • wp-stack-connect/trunk/init.php

    r3063698 r3076247  
    55 * Plugin URI: https://my.wp-stack.co/
    66 * 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.0
     7 * Version: 1.0.1
    88 * Author: wp-stack.co
    99 * Author URI: https://wp-stack.co/
     
    1919// require_once dirname( __FILE__ ) . '/includes/wp/wpstack_connect_puc.php';
    2020require_once dirname( __FILE__ ) . '/includes/wp/wp_site_info.php';
     21require_once dirname( __FILE__ ) . '/includes/wp/wp_config_manager.php';
    2122require_once dirname( __FILE__ ) . '/includes/callback/class-wp-stack-connect-request.php';
    2223
     
    4849}
    4950
    50 $settings   = new WPStack_Connect_Wp_Settings();
    51 $site_info  = new WPStack_Connect_Site_Info();
    52 $_request   = [];
     51if ( ! function_exists( 'wpstack_service' ) ) {
    5352
    54 if ( ( array_key_exists( 'wsparamsmerge', $_POST ) ) || ( array_key_exists( 'wsparamsmerge', $_GET ) ) ) {
     53    function wpstack_service() {
    5554
    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   = [];
    6558
    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 ) ) ) {
    7160
    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        }
    7671
    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';
    9277
    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();
    9582
    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            }
    9898
    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        }
    110118    }
    111119}
     
    118126    add_action( 'init', 'wpstack_scheduled_post_status' );
    119127    add_action( 'init', 'wpstack_override_htaccess_bps' );
     128    add_action( 'init', 'wpstack_service' );
    120129    add_action( 'admin_footer-edit.php', 'wpstack_status_into_inline_edit' );
    121130}
  • wp-stack-connect/trunk/readme.txt

    r3063698 r3076247  
    1212Wp-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.
    1313
    14 We bring all your websites and data that matters most to you to one dashboard so you dont jump over multiple tabs, accounts, and tools.
     14We 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.
    1515
    1616== Description ==
     
    1818Wp-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.
    1919
    20 We bring all your websites and data that matters most to you to one dashboard so you dont jump over multiple tabs, accounts, and tools.
     20We 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.
    2121
    22221. Publish articles to your website in a single click from Google docs or Docx files.
     
    120120* 2023-12-26
    121121* 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  
    2626delete_option( 'wpstack_connect_blocked_settings' );
    2727delete_option( 'wpstack_connect_last_sent_wp_info' );
     28delete_option( 'wpstack_connect_message_status' );
    2829
    2930wp_clear_scheduled_hook( 'wpstack_cron_added_links' );
  • wp-stack-connect/trunk/wp-stack-connect-install.php

    r3063698 r3076247  
    2929    $connection = new WPStack_Connect_Connection();
    3030    $connection->activate();
     31    $wpstack_debug_log = new WPStack_Connect_Debug_Log_Core(null, null);
     32    $wpstack_debug_log->activate();
    3133}
    3234
     
    3840    $connection = new WPStack_Connect_Connection();
    3941    $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();
    4045    wpstack_uninstall_backup_components();
    4146    wpstack_remove_cron_job();
     
    5459    add_option( 'wpstack_connect_connected_status', 'disconnect' );
    5560    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    }
    5664
    5765}
     
    162170    delete_option( 'wpstack_connect_connected_status' );
    163171    delete_option( 'wpstack_connect_enable_track_log' );
     172    delete_option( 'wpstack_connect_message_status' );
    164173}
    165174
     
    351360        if (
    352361            $wpdb->get_var(
    353                 $wpdb->prepare("SHOW TABLES LIKE %i", $table_name)
     362                $wpdb->prepare("SHOW TABLES LIKE %s", $table_name)
    354363            ) !== $table_name
    355364        ) {
     
    422431}
    423432
     433if ( ! 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
    424446if ( ! function_exists( 'wpstack_remove_cron_job' ) ) {
    425447
Note: See TracChangeset for help on using the changeset viewer.