Plugin Directory

Changeset 3218292


Ignore:
Timestamp:
01/07/2025 11:25:04 AM (14 months ago)
Author:
instawp
Message:

Update to version 0.1.0.75 from GitHub

Location:
instawp-connect
Files:
24 edited
1 copied

Legend:

Unmodified
Added
Removed
  • instawp-connect/tags/0.1.0.75/includes/apis/class-instawp-rest-api-manage.php

    r3213354 r3218292  
    5858
    5959        register_rest_route( $this->namespace . '/' . $this->version_2 . '/manage', '/auto-update', array(
    60             array(
    61                 'methods'             => 'GET',
    62                 'callback'            => array( $this, 'get_auto_update' ),
    63                 'permission_callback' => '__return_true',
    64             ),
    65             array(
    66                 'methods'             => 'POST',
    67                 'callback'            => array( $this, 'set_auto_update' ),
    68                 'permission_callback' => '__return_true',
    69             ),
    70         ) );
     60            array(
     61                'methods'             => 'GET',
     62                'callback'            => array( $this, 'get_auto_update' ),
     63                'permission_callback' => '__return_true',
     64            ),
     65            array(
     66                'methods'             => 'POST',
     67                'callback'            => array( $this, 'set_auto_update' ),
     68                'permission_callback' => '__return_true',
     69            ),
     70        ) );
    7171
    7272        register_rest_route( $this->namespace . '/' . $this->version_2 . '/manage', '/configuration', array(
     
    286286    }
    287287
    288     /**
    289     * Handle response to retrieve the defined constant values.
    290     *
    291     * @param WP_REST_Request $request
    292     *
    293     * @return WP_REST_Response
    294     */
    295     public function get_auto_update( WP_REST_Request $request ) {
    296 
    297         $response = $this->validate_api_request( $request );
    298         if ( is_wp_error( $response ) ) {
    299             return $this->throw_error( $response );
    300         }
    301 
    302         try {
    303             $wp_config = new Helpers\WPConfig( array(
    304                 'AUTOMATIC_UPDATER_DISABLED',
    305                 'WP_AUTO_UPDATE_CORE',
    306             ), false, true );
    307             $response  = $wp_config->get();
    308         } catch ( \Exception $e ) {
    309             $response = array(
    310                 'success' => false,
    311                 'message' => $e->getMessage(),
    312             );
    313         }
    314 
    315         return $this->send_response( $response );
    316     }
     288    /**
     289    * Handle response to retrieve the defined constant values.
     290    *
     291    * @param WP_REST_Request $request
     292    *
     293    * @return WP_REST_Response
     294    */
     295    public function get_auto_update( WP_REST_Request $request ) {
     296
     297        $response = $this->validate_api_request( $request );
     298        if ( is_wp_error( $response ) ) {
     299            return $this->throw_error( $response );
     300        }
     301
     302        try {
     303            $wp_config = new Helpers\WPConfig( array(
     304                'AUTOMATIC_UPDATER_DISABLED',
     305                'WP_AUTO_UPDATE_CORE',
     306            ), false, true );
     307            $response  = $wp_config->get();
     308        } catch ( \Exception $e ) {
     309            $response = array(
     310                'success' => false,
     311                'message' => $e->getMessage(),
     312            );
     313        }
     314
     315        return $this->send_response( $response );
     316    }
    317317
    318318    /**
     
    334334        $plugin_theme = $request->get_param( 'plugin-theme' );
    335335
    336         if ( ! empty( $wp_config ) ) {
    337             try {
    338                 $wp_config     = new Helpers\WPConfig( array(
    339                     'AUTOMATIC_UPDATER_DISABLED' => ! empty( $wp_config['updater_disabled'] ) ? $wp_config['updater_disabled'] : false,
    340                     'WP_AUTO_UPDATE_CORE'        => ! empty( $wp_config['auto_update_core'] ) ? $wp_config['auto_update_core'] : false,
    341                 ) );
    342                 $response['wp-config'] = $wp_config->set();
    343 
    344                 wp_cache_flush();
    345             } catch ( \Exception $e ) {
    346                 $response['wp-config'] = array(
    347                     'success' => false,
    348                     'message' => $e->getMessage(),
    349                 );
    350             }
    351         }
    352 
    353         if ( ! empty( $plugin_theme ) ) {
    354             foreach ( $plugin_theme as $key => $param ) {
    355                 $type  = isset( $param['type'] ) ? $param['type'] : 'plugin';
    356                 $asset = isset( $param['asset'] ) ? $param['asset'] : '';
    357                 $state = isset( $param['state'] ) ? $param['state'] : false;
    358 
    359                 if ( 'plugin' === $type ) {
    360                     if ( ! function_exists( 'get_plugins' ) ) {
    361                         require_once ABSPATH . 'wp-admin/includes/plugin.php';
    362                     }
    363 
    364                     $option = 'auto_update_plugins';
    365 
    366                     /** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
    367                     $all_items = apply_filters( 'all_plugins', get_plugins() );
    368                 } elseif ( 'theme' === $type ) {
    369                     if ( ! function_exists( 'wp_get_themes' ) ) {
    370                         require_once ABSPATH . 'wp-includes/theme.php';
    371                     }
    372 
    373                     $option    = 'auto_update_themes';
    374                     $all_items = wp_get_themes();
    375                 }
    376 
    377                 if ( ! isset( $option ) || ! isset( $all_items ) ) {
    378                     $response['plugin-theme'][ $key ] = array(
    379                         'success' => false,
    380                         'message' => __( 'Invalid data. Unknown type.', 'instawp-connect' ),
    381                     );
    382                     continue;
    383                 }
    384 
    385                 if ( ! array_key_exists( $asset, $all_items ) ) {
    386                     $response['plugin-theme'][ $key ] = array(
    387                         'success' => false,
    388                         'message' => __( 'Invalid data. The item does not exist.', 'instawp-connect' ),
    389                     );
    390                     continue;
    391                 }
    392 
    393                 $auto_updates = ( array ) get_site_option( $option, array() );
    394 
    395                 if ( false === $state ) {
    396                     $auto_updates = array_diff( $auto_updates, array( $asset ) );
    397                 } else {
    398                     $auto_updates[] = $asset;
    399                     $auto_updates   = array_unique( $auto_updates );
    400                 }
    401 
    402                 // Remove items that have been deleted since the site option was last updated.
    403                 $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
    404 
    405                 update_site_option( $option, $auto_updates );
    406 
    407                 $response['plugin-theme'][ $key ] = array_merge( array(
    408                     'success' => true,
    409                 ), $param );
    410             }
    411         }
     336        if ( ! empty( $wp_config ) ) {
     337            try {
     338                $wp_config             = new Helpers\WPConfig( array(
     339                    'AUTOMATIC_UPDATER_DISABLED' => ! empty( $wp_config['updater_disabled'] ) ? $wp_config['updater_disabled'] : false,
     340                    'WP_AUTO_UPDATE_CORE'        => ! empty( $wp_config['auto_update_core'] ) ? $wp_config['auto_update_core'] : false,
     341                ) );
     342                $response['wp-config'] = $wp_config->set();
     343
     344                wp_cache_flush();
     345            } catch ( \Exception $e ) {
     346                $response['wp-config'] = array(
     347                    'success' => false,
     348                    'message' => $e->getMessage(),
     349                );
     350            }
     351        }
     352
     353        if ( ! empty( $plugin_theme ) ) {
     354            foreach ( $plugin_theme as $key => $param ) {
     355                $type  = isset( $param['type'] ) ? $param['type'] : 'plugin';
     356                $asset = isset( $param['asset'] ) ? $param['asset'] : '';
     357                $state = isset( $param['state'] ) ? $param['state'] : false;
     358
     359                if ( 'plugin' === $type ) {
     360                    if ( ! function_exists( 'get_plugins' ) ) {
     361                        require_once ABSPATH . 'wp-admin/includes/plugin.php';
     362                    }
     363
     364                    $option = 'auto_update_plugins';
     365
     366                    /** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
     367                    $all_items = apply_filters( 'all_plugins', get_plugins() );
     368                } elseif ( 'theme' === $type ) {
     369                    if ( ! function_exists( 'wp_get_themes' ) ) {
     370                        require_once ABSPATH . 'wp-includes/theme.php';
     371                    }
     372
     373                    $option    = 'auto_update_themes';
     374                    $all_items = wp_get_themes();
     375                }
     376
     377                if ( ! isset( $option ) || ! isset( $all_items ) ) {
     378                    $response['plugin-theme'][ $key ] = array(
     379                        'success' => false,
     380                        'message' => __( 'Invalid data. Unknown type.', 'instawp-connect' ),
     381                    );
     382                    continue;
     383                }
     384
     385                if ( ! array_key_exists( $asset, $all_items ) ) {
     386                    $response['plugin-theme'][ $key ] = array(
     387                        'success' => false,
     388                        'message' => __( 'Invalid data. The item does not exist.', 'instawp-connect' ),
     389                    );
     390                    continue;
     391                }
     392
     393                $auto_updates = ( array ) get_site_option( $option, array() );
     394
     395                if ( false === $state ) {
     396                    $auto_updates = array_diff( $auto_updates, array( $asset ) );
     397                } else {
     398                    $auto_updates[] = $asset;
     399                    $auto_updates   = array_unique( $auto_updates );
     400                }
     401
     402                // Remove items that have been deleted since the site option was last updated.
     403                $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
     404
     405                update_site_option( $option, $auto_updates );
     406
     407                $response['plugin-theme'][ $key ] = array_merge( array(
     408                    'success' => true,
     409                ), $param );
     410            }
     411        }
    412412
    413413        return $this->send_response( $response );
     
    428428        }
    429429
    430         try {
    431             $wp_config_params = $request->get_param( 'wp-config' );
    432             $params           = ! is_array( $wp_config_params ) ? array() : $wp_config_params;
    433 
    434             $wp_config = new Helpers\WPConfig( $params );
    435             $response  = $wp_config->get();
    436         } catch ( \Exception $e ) {
    437             $response = array(
    438                 'success' => false,
    439                 'message' => $e->getMessage(),
    440             );
    441         }
     430        try {
     431            $wp_config_params = $request->get_param( 'wp-config' );
     432            $params           = ! is_array( $wp_config_params ) ? array() : $wp_config_params;
     433
     434            $wp_config = new Helpers\WPConfig( $params );
     435            $response  = $wp_config->get();
     436        } catch ( \Exception $e ) {
     437            $response = array(
     438                'success' => false,
     439                'message' => $e->getMessage(),
     440            );
     441        }
    442442
    443443        return $this->send_response( $response );
     
    461461        $params           = ! is_array( $wp_config_params ) ? array() : $wp_config_params;
    462462
    463         try {
    464             $wp_config = new Helpers\WPConfig( $params );
    465             $response  = $wp_config->set();
    466 
    467             wp_cache_flush();
    468         } catch ( \Exception $e ) {
    469             $response = array(
    470                 'success' => false,
    471                 'message' => $e->getMessage(),
    472             );
    473         }
     463        try {
     464            $wp_config = new Helpers\WPConfig( $params );
     465            $response  = $wp_config->set();
     466
     467            wp_cache_flush();
     468        } catch ( \Exception $e ) {
     469            $response = array(
     470                'success' => false,
     471                'message' => $e->getMessage(),
     472            );
     473        }
    474474
    475475        return $this->send_response( $response );
     
    493493        $params           = ! is_array( $wp_config_params ) ? array() : $wp_config_params;
    494494
    495         try {
    496             $wp_config = new Helpers\WPConfig( $params );
    497             $response  = $wp_config->delete();
    498 
    499             wp_cache_flush();
    500         } catch ( \Exception $e ) {
    501             $response = array(
    502                 'success' => false,
    503                 'message' => $e->getMessage(),
    504             );
    505         }
     495        try {
     496            $wp_config = new Helpers\WPConfig( $params );
     497            $response  = $wp_config->delete();
     498
     499            wp_cache_flush();
     500        } catch ( \Exception $e ) {
     501            $response = array(
     502                'success' => false,
     503                'message' => $e->getMessage(),
     504            );
     505        }
    506506
    507507        return $this->send_response( $response );
     
    525525        $params = $this->filter_params( $request );
    526526
    527         if ( username_exists( $params['user_login'] ) ) {
    528             return $this->send_response( array(
    529                 'success' => false,
    530                 'message' => 'Username is already in use!',
    531             ) );
    532         }
    533 
    534         if ( email_exists( $params['user_email'] ) ) {
    535             return $this->send_response( array(
    536                 'success' => false,
    537                 'message' => 'Email is already in use!',
    538             ) );
    539         }
     527        if ( username_exists( $params['user_login'] ) ) {
     528            return $this->send_response( array(
     529                'success' => false,
     530                'message' => 'Username is already in use!',
     531            ) );
     532        }
     533
     534        if ( email_exists( $params['user_email'] ) ) {
     535            return $this->send_response( array(
     536                'success' => false,
     537                'message' => 'Email is already in use!',
     538            ) );
     539        }
    540540
    541541        if ( ! function_exists( 'wp_insert_user' ) ) {
     
    551551        }
    552552
    553         $count_users  = count_users();
    554         $users        = $count_users['total_users'];
     553        $count_users = count_users();
     554        $total_users = $count_users['total_users'];
    555555
    556556        return $this->send_response( array(
    557557            'success' => true,
    558             'count' => $users,
     558            'count'   => $total_users,
    559559        ) );
    560560    }
  • instawp-connect/tags/0.1.0.75/includes/apis/class-instawp-rest-api.php

    r3216309 r3218292  
    138138        $api_key              = isset( $parameters['api_key'] ) ? sanitize_text_field( $parameters['api_key'] ) : '';
    139139        $api_domain           = isset( $parameters['api_domain'] ) ? sanitize_text_field( $parameters['api_domain'] ) : '';
     140        $plan_id              = isset( $parameters['advance_connect_plan_id'] ) ? intval( $parameters['advance_connect_plan_id'] ) : 0;
    140141        $api_domain           = rtrim( $api_domain, '/' );
    141142
     
    219220        // If api_domain is passed then, set it
    220221        if ( ! empty( $api_domain ) ) {
    221             if ( defined( 'INSTAWP_API_DOMAIN' ) ) {
    222                 Helper::set_api_domain( INSTAWP_API_DOMAIN );
    223             } elseif ( in_array( $api_domain, array( 'https://stage.instawp.io', 'https://app.instawp.io' ) ) ) {
    224                 $api_domain = rtrim( $api_domain, '/' );
    225                 Helper::set_api_domain( $api_domain );
    226             } else {
     222            // Use constant if defined, otherwise validate allowed domains
     223            $domain_to_set = defined( 'INSTAWP_API_DOMAIN' )
     224                ? INSTAWP_API_DOMAIN
     225                : ( in_array( $api_domain, array( 'https://stage.instawp.io', 'https://app.instawp.io' ) ) ? $api_domain : '' );
     226               
     227            if ( empty( $domain_to_set ) ) {
    227228                return $this->send_response( array(
    228229                    'status'  => false,
     
    230231                ) );
    231232            }
     233           
     234            Helper::set_api_domain( $domain_to_set );
     235        }
     236
     237        if ( ! empty( $plan_id ) ) {
     238            Option::update_option( 'instawp_connect_plan_id', $plan_id );
    232239        }
    233240
  • instawp-connect/tags/0.1.0.75/includes/class-instawp-ajax.php

    r3216309 r3218292  
    44use InstaWP\Connect\Helpers\Curl;
    55use InstaWP\Connect\Helpers\DatabaseManager;
    6 use InstaWP\Connect\Helpers\FileManager;
    76use InstaWP\Connect\Helpers\Helper;
    87use InstaWP\Connect\Helpers\Option;
     
    3332
    3433        if ( ! current_user_can( 'manage_options' ) ) {
    35             wp_send_json_error( array( 'updated' => false, 'permission' => false ) );
     34            wp_send_json_error( array(
     35                'updated'    => false,
     36                'permission' => false,
     37            ) );
    3638        }
    3739
     
    4547
    4648        if ( isset( $response[ INSTAWP_PLUGIN_FILE ] ) && isset( $response[ INSTAWP_PLUGIN_FILE ]['success'] ) && (bool) $response[ INSTAWP_PLUGIN_FILE ]['success'] === true ) {
    47             wp_send_json_success( array( 'updated' => true, 'response' => $response ) );
    48         }
    49 
    50         wp_send_json_error( array( 'updated' => false, 'response' => $response ) );
     49            wp_send_json_success( array(
     50                'updated'  => true,
     51                'response' => $response,
     52            ) );
     53        }
     54
     55        wp_send_json_error( array(
     56            'updated'  => false,
     57            'response' => $response,
     58        ) );
    5159    }
    5260
     
    521529
    522530                if ( in_array( $data['full_path'], array( $theme_path, $template_path, $themes_dir, $themes_dir . '/index.php' ) )
    523                      || strpos( $data['full_path'], $theme_path ) !== false
    524                      || strpos( $data['full_path'], $template_path ) !== false ) {
     531                    || strpos( $data['full_path'], $theme_path ) !== false
     532                    || strpos( $data['full_path'], $template_path ) !== false ) {
    525533
    526534                    $theme_item_checked = false;
     
    534542
    535543                if ( in_array( $data['full_path'], array( wp_normalize_path( WP_PLUGIN_DIR ), wp_normalize_path( WP_PLUGIN_DIR ) . '/index.php' ) )
    536                      || in_array( basename( $data['relative_path'] ), array_map( 'dirname', $active_plugins ) ) ) {
     544                    || in_array( basename( $data['relative_path'] ), array_map( 'dirname', $active_plugins ) ) ) {
    537545
    538546                    $plugin_item_checked = false;
  • instawp-connect/tags/0.1.0.75/includes/class-instawp-cli.php

    r3208404 r3218292  
    88use InstaWP\Connect\Helpers\WPConfig;
    99use InstaWP\Connect\Helpers\Option;
     10use InstaWP\Connect\Helpers\WPScanner;
    1011
    1112if ( ! class_exists( 'INSTAWP_CLI_Commands' ) ) {
     
    123124         */
    124125        public function handle_instawp_commands( $args, $assoc_args ) {
    125             if ( isset( $args[0] ) && $args[0] === 'local' ) {
    126                 if ( isset( $args[1] ) && $args[1] === 'push' ) {
    127                     $this->cli_local_push();
    128                 }
    129 
    130                 return true;
    131             }
    132 
    133             if ( isset( $args[0] ) && $args[0] === 'set-waas-mode' ) {
    134                 if ( isset( $args[1] ) ) {
     126            if ( empty( $args[0] ) ) {
     127                return false;
     128            }
     129       
     130            $command    = $args[0];
     131            $subcommand = isset( $args[1] ) ? $args[1] : '';
     132
     133            // Command handler mapping
     134            $commands = array(
     135                'local'                => array(
     136                    'push' => function() { // wp instawp local push
     137                        $this->cli_local_push();
     138                    },
     139                ),
     140                'set-waas-mode'        => function( $args ) { // wp instawp set-waas-mode https://instawp.com
     141                    if ( empty( $args[0] ) ) {
     142                        WP_CLI::error( 'WaaS URL is required' );
     143                        return false;
     144                    }
     145
    135146                    try {
    136147                        $wp_config = new WPConfig( array(
    137148                            'INSTAWP_CONNECT_MODE'     => 'WAAS_GO_LIVE',
    138                             'INSTAWP_CONNECT_WAAS_URL' => $args[1],
     149                            'INSTAWP_CONNECT_WAAS_URL' => $args[0],
    139150                        ) );
    140151                        $wp_config->set();
    141152                    } catch ( \Exception $e ) {
    142153                        WP_CLI::error( $e->getMessage() );
    143 
    144                         return false;
    145                     }
     154                        return false;
     155                    }
     156                },
     157                'reset-waas-mode'      => function() { // wp instawp reset-waas-mode
     158                    try {
     159                        $wp_config = new WPConfig( array( 'INSTAWP_CONNECT_MODE', 'INSTAWP_CONNECT_WAAS_URL' ) );
     160                        $wp_config->delete();
     161                    } catch ( \Exception $e ) {
     162                        WP_CLI::error( $e->getMessage() );
     163                        return false;
     164                    }
     165                },
     166                'config-set'           => array(
     167                    'api-key'    => function( $args, $assoc_args ) { // wp instawp config-set api-key 1234567890
     168                        if ( empty( $args[0] ) ) {
     169                            WP_CLI::error( 'API key value is required' );
     170                            return false;
     171                        }
     172
     173                        $jwt     = ! empty( $assoc_args['jwt'] ) ? $assoc_args['jwt'] : '';
     174                        $managed = ! isset( $assoc_args['unmanaged'] );
     175
     176                        Helper::generate_api_key( $args[0], $jwt, $managed );
     177
     178                        if ( isset( $args[1] ) ) {
     179                            $this->set_connect_mode( $args[1] );
     180                        }
     181                    },
     182                    'api-domain' => function( $args ) { // wp instawp config-set api-domain https://instawp.com
     183                        if ( empty( $args[0] ) ) {
     184                            WP_CLI::error( 'API domain value is required' );
     185                            return false;
     186                        }
     187                        Helper::set_api_domain( $args[0] );
     188
     189                        if ( isset( $args[1] ) ) {
     190                            $this->set_connect_mode( $args[1] );
     191                        }
     192                    },
     193                ),
     194                'config-remove'        => function() { // wp instawp config-remove
     195                    $option = new Option();
     196                    $option->delete( array( 'instawp_api_options', 'instawp_connect_id_options' ) );
     197                },
     198                'hard-reset'           => function( $args, $assoc_args ) { // wp instawp hard-reset
     199                    instawp_reset_running_migration( 'hard', false );
     200
     201                    if ( isset( $assoc_args['clear-events'] ) ) {
     202                        instawp_delete_sync_entries();
     203                    }
     204                },
     205                'clear-events'         => function() { // wp instawp clear-events
     206                    instawp_delete_sync_entries();
     207                },
     208                'activate-plan'        => function( $args ) { // wp instawp activate-plan 123
     209                    $plan_id = isset( $args[0] ) ? intval( $args[0] ) : 0;
     210                    if ( empty( $plan_id ) ) {
     211                        WP_CLI::error( __( 'Plan ID is required', 'instawp-connect' ) );
     212                        return false;
     213                    }
     214
     215                    $response = instawp_connect_activate_plan( $plan_id );
     216                    if ( ! $response['success'] ) {
     217                        WP_CLI::error( $response['message'] );
     218                        return false;
     219                    }
     220                },
     221                'refresh-staging-list' => function() { // wp instawp refresh-staging-list
     222                    instawp_set_staging_sites_list();
     223                },
     224                'staging-set'          => function( $args ) { // wp instawp staging-set 123
     225                    if ( empty( $args[0] ) ) {
     226                        WP_CLI::error( __( 'Staging ID is required', 'instawp-connect' ) );
     227                        return false;
     228                    }
     229                    Option::update_option( 'instawp_sync_connect_id', intval( $args[0] ) );
     230                    Option::update_option( 'instawp_is_staging', true );
     231
     232                    instawp_get_source_site_detail();
     233                },
     234                'reset'                => array(
     235                    'staging' => function() { // wp instawp reset staging
     236                        delete_option( 'instawp_sync_connect_id' );
     237                        delete_option( 'instawp_is_staging' );
     238
     239                        instawp_reset_running_migration();
     240                    },
     241                ),
     242                'scan'                 => array(
     243                    'summary'   => function() { // wp instawp scan summary
     244                        $this->handle_scan_summary();
     245                    },
     246                    'slow-item' => function() { // wp instawp scan slow-item
     247                        $this->handle_scan_slow_items();
     248                    },
     249                ),
     250            );
     251       
     252            // Execute command if it exists
     253            if ( isset( $commands[ $command ] ) ) {
     254                unset( $args[0] );
     255                $args = array_values( $args );
     256               
     257                if ( is_array( $commands[ $command ] ) && isset( $commands[ $command ][ $subcommand ] ) && is_callable( $commands[ $command ][ $subcommand ] ) ) {
     258                    unset( $args[0] );
     259                    $args = array_values( $args );
     260
     261                    return $commands[ $command ][ $subcommand ]( $args, $assoc_args ) !== false;
     262                } elseif ( is_callable( $commands[ $command ] ) ) {
     263                    return $commands[ $command ]( $args, $assoc_args ) !== false;
    146264                }
    147 
    148                 return true;
    149             }
    150 
    151             if ( isset( $args[0] ) && $args[0] === 'reset-waas-mode' ) {
    152                 try {
    153                     $wp_config = new WPConfig( array( 'INSTAWP_CONNECT_MODE', 'INSTAWP_CONNECT_WAAS_URL' ) );
    154                     $wp_config->delete();
    155                 } catch ( \Exception $e ) {
    156                     WP_CLI::error( $e->getMessage() );
    157 
    158                     return false;
     265            }
     266       
     267            return false;
     268        }
     269
     270        // Set connect mode
     271        private function set_connect_mode( $data ) {
     272            try {
     273                $payload = json_decode( base64_decode( $data ), true );
     274                if ( json_last_error() !== JSON_ERROR_NONE ) {
     275                    throw new \Exception( 'Invalid payload format' );
    159276                }
    160 
    161                 return true;
    162             }
    163 
    164             if ( isset( $args[0] ) && $args[0] === 'config-set' ) {
    165                 if ( isset( $args[1] ) ) {
    166                     if ( $args[1] === 'api-key' ) {
    167                         Helper::instawp_generate_api_key( $args[2] );
    168                     } elseif ( $args[1] === 'api-domain' ) {
    169                         Helper::set_api_domain( $args[2] );
    170                     }
     277   
     278                if ( ! empty( $payload['mode']['name'] ) ) {
     279                    $wp_config = new WPConfig( array( 'INSTAWP_CONNECT_MODE' => $payload['mode']['name'] ) );
     280                    $wp_config->set();
     281                   
     282                    WP_CLI::success( 'Mode configuration updated successfully' );
    171283                }
    172 
    173                 if ( isset( $args[3] ) ) {
    174                     $payload_decoded = base64_decode( $args[3] ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
    175                     $payload         = json_decode( $payload_decoded, true );
    176 
    177                     if ( isset( $payload['mode'] ) ) {
    178                         if ( isset( $payload['mode']['name'] ) ) {
    179                             try {
    180                                 $wp_config = new WPConfig( array( 'INSTAWP_CONNECT_MODE' => $payload['mode']['name'] ) );
    181                                 $wp_config->set();
    182                             } catch ( \Exception $e ) {
    183                                 WP_CLI::error( $e->getMessage() );
    184 
    185                                 return false;
    186                             }
    187                         }
    188                     }
    189                 }
    190 
    191                 return true;
    192             }
    193 
    194             if ( isset( $args[0] ) && $args[0] === 'config-remove' ) {
    195                 $option = new \InstaWP\Connect\Helpers\Option();
    196                 $option->delete( array( 'instawp_api_options', 'instawp_connect_id_options' ) );
    197 
    198                 return true;
    199             }
    200 
    201             if ( isset( $args[0] ) && $args[0] === 'hard-reset' ) {
    202                 instawp_reset_running_migration( 'hard', false );
    203 
    204                 if ( ! empty( $assoc_args['clear-events'] ) ) {
    205                     instawp_delete_sync_entries();
    206                 }
    207 
    208                 return true;
    209             }
    210 
    211             if ( isset( $args[0] ) && $args[0] === 'clear-events' ) {
    212                 instawp_delete_sync_entries();
    213 
    214                 return true;
    215             }
    216 
    217 
    218             if ( isset( $args[0] ) && $args[0] === 'activate-plan' ) {
    219                 $plan_id = isset( $args[1] ) ? intval( $args[1] ) : 0;
    220                 if ( ! $plan_id ) {
    221                     WP_CLI::error( esc_html__( 'Plan ID is required', 'instawp-connect' ) );
    222 
    223                     return false;
    224                 }
    225 
    226                 $response = instawp_connect_activate_plan( $plan_id );
    227                 if ( ! $response['success'] ) {
    228                     WP_CLI::error( $response['message'] );
    229 
    230                     return false;
    231                 }
    232 
    233                 return true;
    234             }
    235 
    236             if ( isset( $args[0] ) && $args[0] === 'refresh-staging-list' ) {
    237                 instawp_set_staging_sites_list();
    238 
    239                 return true;
    240             }
    241 
    242             if ( isset( $args[0] ) && $args[0] === 'staging-set' && ! empty( $args[1] ) ) {
    243                 Option::update_option( 'instawp_sync_connect_id', intval( $args[1] ) );
    244                 Option::update_option( 'instawp_is_staging', true );
    245                 instawp_get_source_site_detail();
    246 
    247                 return true;
    248             }
    249 
    250             if ( isset( $args[0] ) && $args[0] === 'reset' ) {
    251                 if ( isset( $args[1] ) && $args[1] === 'staging' ) {
    252                     delete_option( 'instawp_sync_connect_id' );
    253                     delete_option( 'instawp_is_staging' );
    254                     instawp_reset_running_migration();
    255                 }
    256             }
    257 
    258             if ( isset( $args[0] ) && $args[0] === 'scan' ) {
    259                 if ( isset( $args[1] ) && $args[1] === 'summary' ) {
    260                     $wp_scanner  = new \InstaWP\Connect\Helpers\WPScanner();
    261                     $summary_res = $wp_scanner->scan_summary();
    262 
    263                     if ( is_wp_error( $summary_res ) ) {
    264                         WP_CLI::error( $summary_res->get_error_message() );
    265 
    266                         return false;
    267                     }
    268 
    269                     if ( ! is_array( $summary_res ) ) {
    270                         WP_CLI::error( esc_html__( 'Failed: Could not create performance summary.', 'instawp-connect' ) );
    271 
    272                         return false;
    273                     }
    274 
    275                     WP_CLI::success( esc_html__( 'Performance Summary of this website is given below:', 'instawp-connect' ) );
    276 
    277                     $this->render_cli_from_array( $summary_res );
    278                 }
    279 
    280                 if ( isset( $args[1] ) && $args[1] === 'slow-item' ) {
    281                     $wp_scanner = new \InstaWP\Connect\Helpers\WPScanner();
    282                     $slow_items = $wp_scanner->scan_slow_items();
    283 
    284                     if ( is_wp_error( $slow_items ) ) {
    285                         WP_CLI::error( $slow_items->get_error_message() );
    286 
    287                         return false;
    288                     }
    289 
    290                     if ( ! is_array( $slow_items ) ) {
    291                         WP_CLI::error( esc_html__( 'Failed: Could not calculate slow items.', 'instawp-connect' ) );
    292 
    293                         return false;
    294                     }
    295 
    296                     $slow_items_table = array();
    297                     $counter          = 0;
    298                     $fields           = array( 'ID', 'Name', 'Type', 'Time Taken' );
    299 
    300                     foreach ( $slow_items as $slow_item ) {
    301                         ++ $counter;
    302                         $slow_items_table[] = array(
    303                             'ID'         => $counter,
    304                             'Name'       => $slow_item[2],
    305                             'Type'       => $slow_item[3],
    306                             'Time Taken' => $slow_item[1],
    307                         );
    308                     }
    309 
    310                     WP_CLI::success( esc_html__( 'Slow items of this website are given below: (Top is the slowest one)', 'instawp-connect' ) );
    311 
    312                     WP_CLI\Utils\format_items( 'table', $slow_items_table, $fields );
    313                 }
    314             }
    315 
    316             return true;
     284            } catch ( \Exception $e ) {
     285                WP_CLI::error( 'Failed to configure mode: ' . $e->getMessage() );
     286                return false;
     287            }
     288        }
     289       
     290        // Helper methods for scan functionality
     291        private function handle_scan_summary() {
     292            $wp_scanner = new WPScanner();
     293            $summary_res = $wp_scanner->scan_summary();
     294       
     295            if ( is_wp_error($summary_res) ) {
     296                WP_CLI::error($summary_res->get_error_message());
     297                return false;
     298            }
     299       
     300            if ( ! is_array($summary_res) ) {
     301                WP_CLI::error(__('Failed: Could not create performance summary.', 'instawp-connect'));
     302                return false;
     303            }
     304       
     305            WP_CLI::success(__('Performance Summary of this website is given below:', 'instawp-connect'));
     306            $this->render_cli_from_array($summary_res);
     307        }
     308       
     309        private function handle_scan_slow_items() {
     310            $wp_scanner = new WPScanner();
     311            $slow_items = $wp_scanner->scan_slow_items();
     312       
     313            if ( is_wp_error( $slow_items ) || ! is_array( $slow_items ) ) {
     314                WP_CLI::error( __( 'Failed: Could not calculate slow items.', 'instawp-connect' ) );
     315                return false;
     316            }
     317       
     318            $slow_items_table = array_map( function( $item, $index ) {
     319                return array(
     320                    'ID'         => $index + 1,
     321                    'Name'       => $item[2],
     322                    'Type'       => $item[3],
     323                    'Time Taken' => $item[1],
     324                );
     325            }, $slow_items, array_keys( $slow_items ) );
     326       
     327            WP_CLI::success( __( 'Slow items of this website are given below: (Top is the slowest one)', 'instawp-connect' ) );
     328            WP_CLI\Utils\format_items( 'table', $slow_items_table, array( 'ID', 'Name', 'Type', 'Time Taken' ) );
    317329        }
    318330
  • instawp-connect/tags/0.1.0.75/includes/class-instawp-tools.php

    r3216309 r3218292  
    358358            $migrate_settings['excluded_paths'][] = 'wp-includes';
    359359            $migrate_settings['excluded_paths'][] = 'wp-cli.yml';
    360 //          $migrate_settings['excluded_paths'][] = 'index.php';
    361 //          $migrate_settings['excluded_paths'][] = 'wp-load.php';
    362 //          $migrate_settings['excluded_paths'][] = 'wp-activate.php';
    363 //          $migrate_settings['excluded_paths'][] = 'wp-blog-header.php';
    364 //          $migrate_settings['excluded_paths'][] = 'wp-comments-post.php';
    365 //          $migrate_settings['excluded_paths'][] = 'wp-config-sample.php';
    366 //          $migrate_settings['excluded_paths'][] = 'wp-cron.php';
    367 //          $migrate_settings['excluded_paths'][] = 'wp-links-opml.php';
    368 //          $migrate_settings['excluded_paths'][] = 'wp-login.php';
    369 //          $migrate_settings['excluded_paths'][] = 'wp-mail.php';
    370 //          $migrate_settings['excluded_paths'][] = 'wp-settings.php';
    371 //          $migrate_settings['excluded_paths'][] = 'wp-signup.php';
    372 //          $migrate_settings['excluded_paths'][] = 'wp-trackback.php';
     360//          $migrate_settings['excluded_paths'][] = 'index.php';
     361//          $migrate_settings['excluded_paths'][] = 'wp-load.php';
     362//          $migrate_settings['excluded_paths'][] = 'wp-activate.php';
     363//          $migrate_settings['excluded_paths'][] = 'wp-blog-header.php';
     364//          $migrate_settings['excluded_paths'][] = 'wp-comments-post.php';
     365//          $migrate_settings['excluded_paths'][] = 'wp-config-sample.php';
     366//          $migrate_settings['excluded_paths'][] = 'wp-cron.php';
     367//          $migrate_settings['excluded_paths'][] = 'wp-links-opml.php';
     368//          $migrate_settings['excluded_paths'][] = 'wp-login.php';
     369//          $migrate_settings['excluded_paths'][] = 'wp-mail.php';
     370//          $migrate_settings['excluded_paths'][] = 'wp-settings.php';
     371//          $migrate_settings['excluded_paths'][] = 'wp-signup.php';
     372//          $migrate_settings['excluded_paths'][] = 'wp-trackback.php';
    373373            $migrate_settings['excluded_paths'][] = 'xmlrpc.php';
    374374            $migrate_settings['excluded_paths'][] = '.ftpquota';
     
    379379            $migrate_settings['excluded_paths'][] = 'robots.txt';
    380380
    381 //          if ( empty( $migrate_settings['mode'] ) || 'pull' == $migrate_settings['mode'] ) {
    382 //              $migrate_settings['excluded_paths'][] = $wp_root_dir . '/wp-config.php';
    383 //          }
     381//          if ( empty( $migrate_settings['mode'] ) || 'pull' == $migrate_settings['mode'] ) {
     382//              $migrate_settings['excluded_paths'][] = $wp_root_dir . '/wp-config.php';
     383//          }
    384384        }
    385385
     
    10531053        $excluded_tables_rows = Helper::get_args_option( 'excluded_tables_rows', $migrate_settings, array() );
    10541054
    1055         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_api_options';
    1056         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_connect_id_options';
    1057         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_sync_parent_connect_data';
    1058         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_migration_details';
    1059         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_last_migration_details';
    1060         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_api_key_config_completed';
    1061         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_is_event_syncing';
    1062         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_staging_sites';
    1063         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_is_staging';
    1064         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:schema-ActionScheduler_StoreSchema';
    1065         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:schema-ActionScheduler_LoggerSchema';
    1066         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:action_scheduler_hybrid_store_demarkation';
    1067         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:_transient_timeout_action_scheduler_last_pastdue_actions_check';
    1068         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:_transient_action_scheduler_last_pastdue_actions_check';
     1055        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_api_options';
     1056        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_connect_id_options';
     1057        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_sync_parent_connect_data';
     1058        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_migration_details';
     1059        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_last_migration_details';
     1060        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_api_key_config_completed';
     1061        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_is_event_syncing';
     1062        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_staging_sites';
     1063        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_is_staging';
     1064        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:schema-ActionScheduler_StoreSchema';
     1065        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:schema-ActionScheduler_LoggerSchema';
     1066        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:action_scheduler_hybrid_store_demarkation';
     1067        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:_transient_timeout_action_scheduler_last_pastdue_actions_check';
     1068        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:_transient_action_scheduler_last_pastdue_actions_check';
    10691069
    10701070        $migrate_settings['excluded_tables_rows'] = $excluded_tables_rows;
    10711071
     1072        $migrate_settings['source_ip_address'] = self::get_user_ip_address();
     1073
    10721074        return self::process_migration_settings( $migrate_settings );
     1075    }
     1076
     1077    public static function get_user_ip_address() {
     1078        // Check for IPv6 and IPv4 validation
     1079        $ip_pattern = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^(?:(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:))$/';
     1080
     1081        // Array of possible IP address server variables
     1082        $ip_sources = array(
     1083            'HTTP_CLIENT_IP',
     1084            'HTTP_X_FORWARDED_FOR',
     1085            'HTTP_X_FORWARDED',
     1086            'HTTP_X_CLUSTER_CLIENT_IP',
     1087            'HTTP_FORWARDED_FOR',
     1088            'HTTP_FORWARDED',
     1089            'REMOTE_ADDR',
     1090        );
     1091
     1092        // Loop through possible IP sources
     1093        foreach ( $ip_sources as $source ) {
     1094            if ( isset( $_SERVER[ $source ] ) ) {
     1095                $ip = $_SERVER[ $source ];
     1096
     1097                // Handle X-Forwarded-For header which may contain multiple IPs
     1098                if ( $source === 'HTTP_X_FORWARDED_FOR' ) {
     1099                    $ips = explode( ',', $ip );
     1100                    $ip  = trim( $ips[0] ); // Get the first IP in the list
     1101                }
     1102
     1103                // Validate IP format
     1104                if ( filter_var( $ip, FILTER_VALIDATE_IP ) && preg_match( $ip_pattern, $ip ) ) {
     1105                    return $ip;
     1106                }
     1107            }
     1108        }
     1109
     1110        // If no valid IP is found, return a fallback
     1111        return '0.0.0.0';
    10731112    }
    10741113
  • instawp-connect/tags/0.1.0.75/instawp-connect.php

    r3216309 r3218292  
    88 * Plugin Name:       InstaWP Connect
    99 * Description:       1-click WordPress plugin for Staging, Migrations, Management, Sync and Companion plugin for InstaWP.
    10  * Version:           0.1.0.74
     10 * Version:           0.1.0.75
    1111 * Author:            InstaWP Team
    1212 * Author URI:        https://instawp.com/
     
    2828global $wpdb;
    2929
    30 defined( 'INSTAWP_PLUGIN_VERSION' ) || define( 'INSTAWP_PLUGIN_VERSION', '0.1.0.74' );
     30defined( 'INSTAWP_PLUGIN_VERSION' ) || define( 'INSTAWP_PLUGIN_VERSION', '0.1.0.75' );
    3131defined( 'INSTAWP_API_DOMAIN_PROD' ) || define( 'INSTAWP_API_DOMAIN_PROD', 'https://app.instawp.io' );
    3232
  • instawp-connect/tags/0.1.0.75/migrate/templates/main.php

    r3216309 r3218292  
    5555                <div class="flex justify-between items-center transition-all duration-300">
    5656                    <p class="max-w-[85%]">
    57                         <span class="inline-block"><?php printf( wp_kses_post( __( 'A new version of InstaWP Connect (%s) is available. You are using an older version (%s), it is recommended to update.', 'instawp-connect' ) ), $new_version_number, INSTAWP_PLUGIN_VERSION ); ?></span>
     57                        <span class="inline-block"><?php printf( wp_kses_post( __( 'A new version of InstaWP Connect (%1$s) is available. You are using an older version (%2$s), it is recommended to update.', 'instawp-connect' ) ), $new_version_number, INSTAWP_PLUGIN_VERSION ); ?></span>
    5858                        <span class="instawp-update-notice hidden bg-red-700 text-gray-200 px-1.5 py-[2px] mt-2 rounded-sm transition-all duration-300"><?php esc_html_e( 'Could not update the plugin!', 'instawp-connect' ); ?></span>
    5959                    </p>
  • instawp-connect/tags/0.1.0.75/readme.txt

    r3216309 r3218292  
    55Tested up to: 6.7
    66Requires PHP: 7.0
    7 Stable tag: 0.1.0.74
     7Stable tag: 0.1.0.75
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    9999== Changelog ==
    100100
     101= 0.1.0.75 - 07 January 2025 =
     102- FIX: Added changes to directly connect to the advanced plan.
     103- FIX: Added changes to create connect as unmanaged.
     104- FIX: Fixed pull migration issue.
     105
    101106= 0.1.0.74 - 03 January 2025 =
    102107- NEW: Show warning message if the plugin is not on latest version.
  • instawp-connect/tags/0.1.0.75/uninstall.php

    r3216309 r3218292  
    77    exit;
    88}
     9
     10global $wpdb;
    911
    1012defined( 'INSTAWP_DEFAULT_BACKUP_DIR' ) || define( 'INSTAWP_DEFAULT_BACKUP_DIR', 'instawpbackups' );
     
    2931$api_key     = isset( $api_options['api_key'] ) ? $api_options['api_key'] : '';
    3032$api_url     = isset( $api_options['api_url'] ) ? $api_options['api_url'] : 'https://app.instawp.io';
     33$site_url    = $wpdb->get_var( "SELECT option_value FROM {$wpdb->options} WHERE option_name = 'siteurl'" );
     34$site_url    = empty( $site_url ) ? site_url() : $site_url;
    3135
    3236if ( ! empty( $connect_id ) && ! empty( $api_key ) ) {
     
    3640            'Accept'        => 'application/json',
    3741            'Content-Type'  => 'application/json',
    38             'Referer'       => Helper::wp_site_url(),
     42            'Referer'       => $site_url,
    3943        ),
    4044        'timeout'         => 60,
  • instawp-connect/tags/0.1.0.75/vendor/composer/installed.json

    r3216309 r3218292  
    88                "type": "git",
    99                "url": "https://github.com/InstaWP/connect-helpers.git",
    10                 "reference": "242319c9434567c10b83f52881d0616ce76044fc"
    11             },
    12             "dist": {
    13                 "type": "zip",
    14                 "url": "https://api.github.com/repos/InstaWP/connect-helpers/zipball/242319c9434567c10b83f52881d0616ce76044fc",
    15                 "reference": "242319c9434567c10b83f52881d0616ce76044fc",
     10                "reference": "4e5a060b35cdcc903ee2165e1cb5b2794437cf74"
     11            },
     12            "dist": {
     13                "type": "zip",
     14                "url": "https://api.github.com/repos/InstaWP/connect-helpers/zipball/4e5a060b35cdcc903ee2165e1cb5b2794437cf74",
     15                "reference": "4e5a060b35cdcc903ee2165e1cb5b2794437cf74",
    1616                "shasum": ""
    1717            },
     
    2020                "wp-cli/wp-config-transformer": "^1.3"
    2121            },
    22             "time": "2024-12-27T13:37:12+00:00",
     22            "time": "2025-01-02T11:30:59+00:00",
    2323            "default-branch": true,
    2424            "type": "library",
  • instawp-connect/tags/0.1.0.75/vendor/composer/installed.php

    r3216309 r3218292  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '82b751d64e44a714d57e71807bcf2c5969ee7876',
     6        'reference' => '5e2939ad37db1d19f4609420ae51403a96362415',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '82b751d64e44a714d57e71807bcf2c5969ee7876',
     16            'reference' => '5e2939ad37db1d19f4609420ae51403a96362415',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
     
    2323            'pretty_version' => 'dev-main',
    2424            'version' => 'dev-main',
    25             'reference' => '242319c9434567c10b83f52881d0616ce76044fc',
     25            'reference' => '4e5a060b35cdcc903ee2165e1cb5b2794437cf74',
    2626            'type' => 'library',
    2727            'install_path' => __DIR__ . '/../instawp/connect-helpers',
  • instawp-connect/tags/0.1.0.75/vendor/instawp/connect-helpers/src/Helper.php

    r3216309 r3218292  
    55class Helper {
    66
    7     public static function instawp_generate_api_key( $api_key, $jwt = '' ) {
    8         return self::generate_api_key( $api_key, $jwt );
    9     }
    10 
    11     public static function generate_api_key( $api_key, $jwt = '' ) {
     7    public static function instawp_generate_api_key( $api_key, $jwt = '', $managed = true ) {
     8        return self::generate_api_key( $api_key, $jwt, $managed );
     9    }
     10
     11    public static function generate_api_key( $api_key, $jwt = '', $managed = true ) {
    1212        if ( empty( $api_key ) ) {
    1313            error_log( 'instawp_generate_api_key empty api_key parameter' );
     
    4343            'username'       => base64_encode( self::get_admin_username() ),
    4444            'plan_id'        => self::get_connect_plan_id(),
     45            'managed'        => $managed,
    4546        );
    4647        $connect_response = Curl::do_curl( 'connects', $connect_body, array(), 'POST', 'v1' );
  • instawp-connect/trunk/includes/apis/class-instawp-rest-api-manage.php

    r3213354 r3218292  
    5858
    5959        register_rest_route( $this->namespace . '/' . $this->version_2 . '/manage', '/auto-update', array(
    60             array(
    61                 'methods'             => 'GET',
    62                 'callback'            => array( $this, 'get_auto_update' ),
    63                 'permission_callback' => '__return_true',
    64             ),
    65             array(
    66                 'methods'             => 'POST',
    67                 'callback'            => array( $this, 'set_auto_update' ),
    68                 'permission_callback' => '__return_true',
    69             ),
    70         ) );
     60            array(
     61                'methods'             => 'GET',
     62                'callback'            => array( $this, 'get_auto_update' ),
     63                'permission_callback' => '__return_true',
     64            ),
     65            array(
     66                'methods'             => 'POST',
     67                'callback'            => array( $this, 'set_auto_update' ),
     68                'permission_callback' => '__return_true',
     69            ),
     70        ) );
    7171
    7272        register_rest_route( $this->namespace . '/' . $this->version_2 . '/manage', '/configuration', array(
     
    286286    }
    287287
    288     /**
    289     * Handle response to retrieve the defined constant values.
    290     *
    291     * @param WP_REST_Request $request
    292     *
    293     * @return WP_REST_Response
    294     */
    295     public function get_auto_update( WP_REST_Request $request ) {
    296 
    297         $response = $this->validate_api_request( $request );
    298         if ( is_wp_error( $response ) ) {
    299             return $this->throw_error( $response );
    300         }
    301 
    302         try {
    303             $wp_config = new Helpers\WPConfig( array(
    304                 'AUTOMATIC_UPDATER_DISABLED',
    305                 'WP_AUTO_UPDATE_CORE',
    306             ), false, true );
    307             $response  = $wp_config->get();
    308         } catch ( \Exception $e ) {
    309             $response = array(
    310                 'success' => false,
    311                 'message' => $e->getMessage(),
    312             );
    313         }
    314 
    315         return $this->send_response( $response );
    316     }
     288    /**
     289    * Handle response to retrieve the defined constant values.
     290    *
     291    * @param WP_REST_Request $request
     292    *
     293    * @return WP_REST_Response
     294    */
     295    public function get_auto_update( WP_REST_Request $request ) {
     296
     297        $response = $this->validate_api_request( $request );
     298        if ( is_wp_error( $response ) ) {
     299            return $this->throw_error( $response );
     300        }
     301
     302        try {
     303            $wp_config = new Helpers\WPConfig( array(
     304                'AUTOMATIC_UPDATER_DISABLED',
     305                'WP_AUTO_UPDATE_CORE',
     306            ), false, true );
     307            $response  = $wp_config->get();
     308        } catch ( \Exception $e ) {
     309            $response = array(
     310                'success' => false,
     311                'message' => $e->getMessage(),
     312            );
     313        }
     314
     315        return $this->send_response( $response );
     316    }
    317317
    318318    /**
     
    334334        $plugin_theme = $request->get_param( 'plugin-theme' );
    335335
    336         if ( ! empty( $wp_config ) ) {
    337             try {
    338                 $wp_config     = new Helpers\WPConfig( array(
    339                     'AUTOMATIC_UPDATER_DISABLED' => ! empty( $wp_config['updater_disabled'] ) ? $wp_config['updater_disabled'] : false,
    340                     'WP_AUTO_UPDATE_CORE'        => ! empty( $wp_config['auto_update_core'] ) ? $wp_config['auto_update_core'] : false,
    341                 ) );
    342                 $response['wp-config'] = $wp_config->set();
    343 
    344                 wp_cache_flush();
    345             } catch ( \Exception $e ) {
    346                 $response['wp-config'] = array(
    347                     'success' => false,
    348                     'message' => $e->getMessage(),
    349                 );
    350             }
    351         }
    352 
    353         if ( ! empty( $plugin_theme ) ) {
    354             foreach ( $plugin_theme as $key => $param ) {
    355                 $type  = isset( $param['type'] ) ? $param['type'] : 'plugin';
    356                 $asset = isset( $param['asset'] ) ? $param['asset'] : '';
    357                 $state = isset( $param['state'] ) ? $param['state'] : false;
    358 
    359                 if ( 'plugin' === $type ) {
    360                     if ( ! function_exists( 'get_plugins' ) ) {
    361                         require_once ABSPATH . 'wp-admin/includes/plugin.php';
    362                     }
    363 
    364                     $option = 'auto_update_plugins';
    365 
    366                     /** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
    367                     $all_items = apply_filters( 'all_plugins', get_plugins() );
    368                 } elseif ( 'theme' === $type ) {
    369                     if ( ! function_exists( 'wp_get_themes' ) ) {
    370                         require_once ABSPATH . 'wp-includes/theme.php';
    371                     }
    372 
    373                     $option    = 'auto_update_themes';
    374                     $all_items = wp_get_themes();
    375                 }
    376 
    377                 if ( ! isset( $option ) || ! isset( $all_items ) ) {
    378                     $response['plugin-theme'][ $key ] = array(
    379                         'success' => false,
    380                         'message' => __( 'Invalid data. Unknown type.', 'instawp-connect' ),
    381                     );
    382                     continue;
    383                 }
    384 
    385                 if ( ! array_key_exists( $asset, $all_items ) ) {
    386                     $response['plugin-theme'][ $key ] = array(
    387                         'success' => false,
    388                         'message' => __( 'Invalid data. The item does not exist.', 'instawp-connect' ),
    389                     );
    390                     continue;
    391                 }
    392 
    393                 $auto_updates = ( array ) get_site_option( $option, array() );
    394 
    395                 if ( false === $state ) {
    396                     $auto_updates = array_diff( $auto_updates, array( $asset ) );
    397                 } else {
    398                     $auto_updates[] = $asset;
    399                     $auto_updates   = array_unique( $auto_updates );
    400                 }
    401 
    402                 // Remove items that have been deleted since the site option was last updated.
    403                 $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
    404 
    405                 update_site_option( $option, $auto_updates );
    406 
    407                 $response['plugin-theme'][ $key ] = array_merge( array(
    408                     'success' => true,
    409                 ), $param );
    410             }
    411         }
     336        if ( ! empty( $wp_config ) ) {
     337            try {
     338                $wp_config             = new Helpers\WPConfig( array(
     339                    'AUTOMATIC_UPDATER_DISABLED' => ! empty( $wp_config['updater_disabled'] ) ? $wp_config['updater_disabled'] : false,
     340                    'WP_AUTO_UPDATE_CORE'        => ! empty( $wp_config['auto_update_core'] ) ? $wp_config['auto_update_core'] : false,
     341                ) );
     342                $response['wp-config'] = $wp_config->set();
     343
     344                wp_cache_flush();
     345            } catch ( \Exception $e ) {
     346                $response['wp-config'] = array(
     347                    'success' => false,
     348                    'message' => $e->getMessage(),
     349                );
     350            }
     351        }
     352
     353        if ( ! empty( $plugin_theme ) ) {
     354            foreach ( $plugin_theme as $key => $param ) {
     355                $type  = isset( $param['type'] ) ? $param['type'] : 'plugin';
     356                $asset = isset( $param['asset'] ) ? $param['asset'] : '';
     357                $state = isset( $param['state'] ) ? $param['state'] : false;
     358
     359                if ( 'plugin' === $type ) {
     360                    if ( ! function_exists( 'get_plugins' ) ) {
     361                        require_once ABSPATH . 'wp-admin/includes/plugin.php';
     362                    }
     363
     364                    $option = 'auto_update_plugins';
     365
     366                    /** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
     367                    $all_items = apply_filters( 'all_plugins', get_plugins() );
     368                } elseif ( 'theme' === $type ) {
     369                    if ( ! function_exists( 'wp_get_themes' ) ) {
     370                        require_once ABSPATH . 'wp-includes/theme.php';
     371                    }
     372
     373                    $option    = 'auto_update_themes';
     374                    $all_items = wp_get_themes();
     375                }
     376
     377                if ( ! isset( $option ) || ! isset( $all_items ) ) {
     378                    $response['plugin-theme'][ $key ] = array(
     379                        'success' => false,
     380                        'message' => __( 'Invalid data. Unknown type.', 'instawp-connect' ),
     381                    );
     382                    continue;
     383                }
     384
     385                if ( ! array_key_exists( $asset, $all_items ) ) {
     386                    $response['plugin-theme'][ $key ] = array(
     387                        'success' => false,
     388                        'message' => __( 'Invalid data. The item does not exist.', 'instawp-connect' ),
     389                    );
     390                    continue;
     391                }
     392
     393                $auto_updates = ( array ) get_site_option( $option, array() );
     394
     395                if ( false === $state ) {
     396                    $auto_updates = array_diff( $auto_updates, array( $asset ) );
     397                } else {
     398                    $auto_updates[] = $asset;
     399                    $auto_updates   = array_unique( $auto_updates );
     400                }
     401
     402                // Remove items that have been deleted since the site option was last updated.
     403                $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
     404
     405                update_site_option( $option, $auto_updates );
     406
     407                $response['plugin-theme'][ $key ] = array_merge( array(
     408                    'success' => true,
     409                ), $param );
     410            }
     411        }
    412412
    413413        return $this->send_response( $response );
     
    428428        }
    429429
    430         try {
    431             $wp_config_params = $request->get_param( 'wp-config' );
    432             $params           = ! is_array( $wp_config_params ) ? array() : $wp_config_params;
    433 
    434             $wp_config = new Helpers\WPConfig( $params );
    435             $response  = $wp_config->get();
    436         } catch ( \Exception $e ) {
    437             $response = array(
    438                 'success' => false,
    439                 'message' => $e->getMessage(),
    440             );
    441         }
     430        try {
     431            $wp_config_params = $request->get_param( 'wp-config' );
     432            $params           = ! is_array( $wp_config_params ) ? array() : $wp_config_params;
     433
     434            $wp_config = new Helpers\WPConfig( $params );
     435            $response  = $wp_config->get();
     436        } catch ( \Exception $e ) {
     437            $response = array(
     438                'success' => false,
     439                'message' => $e->getMessage(),
     440            );
     441        }
    442442
    443443        return $this->send_response( $response );
     
    461461        $params           = ! is_array( $wp_config_params ) ? array() : $wp_config_params;
    462462
    463         try {
    464             $wp_config = new Helpers\WPConfig( $params );
    465             $response  = $wp_config->set();
    466 
    467             wp_cache_flush();
    468         } catch ( \Exception $e ) {
    469             $response = array(
    470                 'success' => false,
    471                 'message' => $e->getMessage(),
    472             );
    473         }
     463        try {
     464            $wp_config = new Helpers\WPConfig( $params );
     465            $response  = $wp_config->set();
     466
     467            wp_cache_flush();
     468        } catch ( \Exception $e ) {
     469            $response = array(
     470                'success' => false,
     471                'message' => $e->getMessage(),
     472            );
     473        }
    474474
    475475        return $this->send_response( $response );
     
    493493        $params           = ! is_array( $wp_config_params ) ? array() : $wp_config_params;
    494494
    495         try {
    496             $wp_config = new Helpers\WPConfig( $params );
    497             $response  = $wp_config->delete();
    498 
    499             wp_cache_flush();
    500         } catch ( \Exception $e ) {
    501             $response = array(
    502                 'success' => false,
    503                 'message' => $e->getMessage(),
    504             );
    505         }
     495        try {
     496            $wp_config = new Helpers\WPConfig( $params );
     497            $response  = $wp_config->delete();
     498
     499            wp_cache_flush();
     500        } catch ( \Exception $e ) {
     501            $response = array(
     502                'success' => false,
     503                'message' => $e->getMessage(),
     504            );
     505        }
    506506
    507507        return $this->send_response( $response );
     
    525525        $params = $this->filter_params( $request );
    526526
    527         if ( username_exists( $params['user_login'] ) ) {
    528             return $this->send_response( array(
    529                 'success' => false,
    530                 'message' => 'Username is already in use!',
    531             ) );
    532         }
    533 
    534         if ( email_exists( $params['user_email'] ) ) {
    535             return $this->send_response( array(
    536                 'success' => false,
    537                 'message' => 'Email is already in use!',
    538             ) );
    539         }
     527        if ( username_exists( $params['user_login'] ) ) {
     528            return $this->send_response( array(
     529                'success' => false,
     530                'message' => 'Username is already in use!',
     531            ) );
     532        }
     533
     534        if ( email_exists( $params['user_email'] ) ) {
     535            return $this->send_response( array(
     536                'success' => false,
     537                'message' => 'Email is already in use!',
     538            ) );
     539        }
    540540
    541541        if ( ! function_exists( 'wp_insert_user' ) ) {
     
    551551        }
    552552
    553         $count_users  = count_users();
    554         $users        = $count_users['total_users'];
     553        $count_users = count_users();
     554        $total_users = $count_users['total_users'];
    555555
    556556        return $this->send_response( array(
    557557            'success' => true,
    558             'count' => $users,
     558            'count'   => $total_users,
    559559        ) );
    560560    }
  • instawp-connect/trunk/includes/apis/class-instawp-rest-api.php

    r3216309 r3218292  
    138138        $api_key              = isset( $parameters['api_key'] ) ? sanitize_text_field( $parameters['api_key'] ) : '';
    139139        $api_domain           = isset( $parameters['api_domain'] ) ? sanitize_text_field( $parameters['api_domain'] ) : '';
     140        $plan_id              = isset( $parameters['advance_connect_plan_id'] ) ? intval( $parameters['advance_connect_plan_id'] ) : 0;
    140141        $api_domain           = rtrim( $api_domain, '/' );
    141142
     
    219220        // If api_domain is passed then, set it
    220221        if ( ! empty( $api_domain ) ) {
    221             if ( defined( 'INSTAWP_API_DOMAIN' ) ) {
    222                 Helper::set_api_domain( INSTAWP_API_DOMAIN );
    223             } elseif ( in_array( $api_domain, array( 'https://stage.instawp.io', 'https://app.instawp.io' ) ) ) {
    224                 $api_domain = rtrim( $api_domain, '/' );
    225                 Helper::set_api_domain( $api_domain );
    226             } else {
     222            // Use constant if defined, otherwise validate allowed domains
     223            $domain_to_set = defined( 'INSTAWP_API_DOMAIN' )
     224                ? INSTAWP_API_DOMAIN
     225                : ( in_array( $api_domain, array( 'https://stage.instawp.io', 'https://app.instawp.io' ) ) ? $api_domain : '' );
     226               
     227            if ( empty( $domain_to_set ) ) {
    227228                return $this->send_response( array(
    228229                    'status'  => false,
     
    230231                ) );
    231232            }
     233           
     234            Helper::set_api_domain( $domain_to_set );
     235        }
     236
     237        if ( ! empty( $plan_id ) ) {
     238            Option::update_option( 'instawp_connect_plan_id', $plan_id );
    232239        }
    233240
  • instawp-connect/trunk/includes/class-instawp-ajax.php

    r3216309 r3218292  
    44use InstaWP\Connect\Helpers\Curl;
    55use InstaWP\Connect\Helpers\DatabaseManager;
    6 use InstaWP\Connect\Helpers\FileManager;
    76use InstaWP\Connect\Helpers\Helper;
    87use InstaWP\Connect\Helpers\Option;
     
    3332
    3433        if ( ! current_user_can( 'manage_options' ) ) {
    35             wp_send_json_error( array( 'updated' => false, 'permission' => false ) );
     34            wp_send_json_error( array(
     35                'updated'    => false,
     36                'permission' => false,
     37            ) );
    3638        }
    3739
     
    4547
    4648        if ( isset( $response[ INSTAWP_PLUGIN_FILE ] ) && isset( $response[ INSTAWP_PLUGIN_FILE ]['success'] ) && (bool) $response[ INSTAWP_PLUGIN_FILE ]['success'] === true ) {
    47             wp_send_json_success( array( 'updated' => true, 'response' => $response ) );
    48         }
    49 
    50         wp_send_json_error( array( 'updated' => false, 'response' => $response ) );
     49            wp_send_json_success( array(
     50                'updated'  => true,
     51                'response' => $response,
     52            ) );
     53        }
     54
     55        wp_send_json_error( array(
     56            'updated'  => false,
     57            'response' => $response,
     58        ) );
    5159    }
    5260
     
    521529
    522530                if ( in_array( $data['full_path'], array( $theme_path, $template_path, $themes_dir, $themes_dir . '/index.php' ) )
    523                      || strpos( $data['full_path'], $theme_path ) !== false
    524                      || strpos( $data['full_path'], $template_path ) !== false ) {
     531                    || strpos( $data['full_path'], $theme_path ) !== false
     532                    || strpos( $data['full_path'], $template_path ) !== false ) {
    525533
    526534                    $theme_item_checked = false;
     
    534542
    535543                if ( in_array( $data['full_path'], array( wp_normalize_path( WP_PLUGIN_DIR ), wp_normalize_path( WP_PLUGIN_DIR ) . '/index.php' ) )
    536                      || in_array( basename( $data['relative_path'] ), array_map( 'dirname', $active_plugins ) ) ) {
     544                    || in_array( basename( $data['relative_path'] ), array_map( 'dirname', $active_plugins ) ) ) {
    537545
    538546                    $plugin_item_checked = false;
  • instawp-connect/trunk/includes/class-instawp-cli.php

    r3208404 r3218292  
    88use InstaWP\Connect\Helpers\WPConfig;
    99use InstaWP\Connect\Helpers\Option;
     10use InstaWP\Connect\Helpers\WPScanner;
    1011
    1112if ( ! class_exists( 'INSTAWP_CLI_Commands' ) ) {
     
    123124         */
    124125        public function handle_instawp_commands( $args, $assoc_args ) {
    125             if ( isset( $args[0] ) && $args[0] === 'local' ) {
    126                 if ( isset( $args[1] ) && $args[1] === 'push' ) {
    127                     $this->cli_local_push();
    128                 }
    129 
    130                 return true;
    131             }
    132 
    133             if ( isset( $args[0] ) && $args[0] === 'set-waas-mode' ) {
    134                 if ( isset( $args[1] ) ) {
     126            if ( empty( $args[0] ) ) {
     127                return false;
     128            }
     129       
     130            $command    = $args[0];
     131            $subcommand = isset( $args[1] ) ? $args[1] : '';
     132
     133            // Command handler mapping
     134            $commands = array(
     135                'local'                => array(
     136                    'push' => function() { // wp instawp local push
     137                        $this->cli_local_push();
     138                    },
     139                ),
     140                'set-waas-mode'        => function( $args ) { // wp instawp set-waas-mode https://instawp.com
     141                    if ( empty( $args[0] ) ) {
     142                        WP_CLI::error( 'WaaS URL is required' );
     143                        return false;
     144                    }
     145
    135146                    try {
    136147                        $wp_config = new WPConfig( array(
    137148                            'INSTAWP_CONNECT_MODE'     => 'WAAS_GO_LIVE',
    138                             'INSTAWP_CONNECT_WAAS_URL' => $args[1],
     149                            'INSTAWP_CONNECT_WAAS_URL' => $args[0],
    139150                        ) );
    140151                        $wp_config->set();
    141152                    } catch ( \Exception $e ) {
    142153                        WP_CLI::error( $e->getMessage() );
    143 
    144                         return false;
    145                     }
     154                        return false;
     155                    }
     156                },
     157                'reset-waas-mode'      => function() { // wp instawp reset-waas-mode
     158                    try {
     159                        $wp_config = new WPConfig( array( 'INSTAWP_CONNECT_MODE', 'INSTAWP_CONNECT_WAAS_URL' ) );
     160                        $wp_config->delete();
     161                    } catch ( \Exception $e ) {
     162                        WP_CLI::error( $e->getMessage() );
     163                        return false;
     164                    }
     165                },
     166                'config-set'           => array(
     167                    'api-key'    => function( $args, $assoc_args ) { // wp instawp config-set api-key 1234567890
     168                        if ( empty( $args[0] ) ) {
     169                            WP_CLI::error( 'API key value is required' );
     170                            return false;
     171                        }
     172
     173                        $jwt     = ! empty( $assoc_args['jwt'] ) ? $assoc_args['jwt'] : '';
     174                        $managed = ! isset( $assoc_args['unmanaged'] );
     175
     176                        Helper::generate_api_key( $args[0], $jwt, $managed );
     177
     178                        if ( isset( $args[1] ) ) {
     179                            $this->set_connect_mode( $args[1] );
     180                        }
     181                    },
     182                    'api-domain' => function( $args ) { // wp instawp config-set api-domain https://instawp.com
     183                        if ( empty( $args[0] ) ) {
     184                            WP_CLI::error( 'API domain value is required' );
     185                            return false;
     186                        }
     187                        Helper::set_api_domain( $args[0] );
     188
     189                        if ( isset( $args[1] ) ) {
     190                            $this->set_connect_mode( $args[1] );
     191                        }
     192                    },
     193                ),
     194                'config-remove'        => function() { // wp instawp config-remove
     195                    $option = new Option();
     196                    $option->delete( array( 'instawp_api_options', 'instawp_connect_id_options' ) );
     197                },
     198                'hard-reset'           => function( $args, $assoc_args ) { // wp instawp hard-reset
     199                    instawp_reset_running_migration( 'hard', false );
     200
     201                    if ( isset( $assoc_args['clear-events'] ) ) {
     202                        instawp_delete_sync_entries();
     203                    }
     204                },
     205                'clear-events'         => function() { // wp instawp clear-events
     206                    instawp_delete_sync_entries();
     207                },
     208                'activate-plan'        => function( $args ) { // wp instawp activate-plan 123
     209                    $plan_id = isset( $args[0] ) ? intval( $args[0] ) : 0;
     210                    if ( empty( $plan_id ) ) {
     211                        WP_CLI::error( __( 'Plan ID is required', 'instawp-connect' ) );
     212                        return false;
     213                    }
     214
     215                    $response = instawp_connect_activate_plan( $plan_id );
     216                    if ( ! $response['success'] ) {
     217                        WP_CLI::error( $response['message'] );
     218                        return false;
     219                    }
     220                },
     221                'refresh-staging-list' => function() { // wp instawp refresh-staging-list
     222                    instawp_set_staging_sites_list();
     223                },
     224                'staging-set'          => function( $args ) { // wp instawp staging-set 123
     225                    if ( empty( $args[0] ) ) {
     226                        WP_CLI::error( __( 'Staging ID is required', 'instawp-connect' ) );
     227                        return false;
     228                    }
     229                    Option::update_option( 'instawp_sync_connect_id', intval( $args[0] ) );
     230                    Option::update_option( 'instawp_is_staging', true );
     231
     232                    instawp_get_source_site_detail();
     233                },
     234                'reset'                => array(
     235                    'staging' => function() { // wp instawp reset staging
     236                        delete_option( 'instawp_sync_connect_id' );
     237                        delete_option( 'instawp_is_staging' );
     238
     239                        instawp_reset_running_migration();
     240                    },
     241                ),
     242                'scan'                 => array(
     243                    'summary'   => function() { // wp instawp scan summary
     244                        $this->handle_scan_summary();
     245                    },
     246                    'slow-item' => function() { // wp instawp scan slow-item
     247                        $this->handle_scan_slow_items();
     248                    },
     249                ),
     250            );
     251       
     252            // Execute command if it exists
     253            if ( isset( $commands[ $command ] ) ) {
     254                unset( $args[0] );
     255                $args = array_values( $args );
     256               
     257                if ( is_array( $commands[ $command ] ) && isset( $commands[ $command ][ $subcommand ] ) && is_callable( $commands[ $command ][ $subcommand ] ) ) {
     258                    unset( $args[0] );
     259                    $args = array_values( $args );
     260
     261                    return $commands[ $command ][ $subcommand ]( $args, $assoc_args ) !== false;
     262                } elseif ( is_callable( $commands[ $command ] ) ) {
     263                    return $commands[ $command ]( $args, $assoc_args ) !== false;
    146264                }
    147 
    148                 return true;
    149             }
    150 
    151             if ( isset( $args[0] ) && $args[0] === 'reset-waas-mode' ) {
    152                 try {
    153                     $wp_config = new WPConfig( array( 'INSTAWP_CONNECT_MODE', 'INSTAWP_CONNECT_WAAS_URL' ) );
    154                     $wp_config->delete();
    155                 } catch ( \Exception $e ) {
    156                     WP_CLI::error( $e->getMessage() );
    157 
    158                     return false;
     265            }
     266       
     267            return false;
     268        }
     269
     270        // Set connect mode
     271        private function set_connect_mode( $data ) {
     272            try {
     273                $payload = json_decode( base64_decode( $data ), true );
     274                if ( json_last_error() !== JSON_ERROR_NONE ) {
     275                    throw new \Exception( 'Invalid payload format' );
    159276                }
    160 
    161                 return true;
    162             }
    163 
    164             if ( isset( $args[0] ) && $args[0] === 'config-set' ) {
    165                 if ( isset( $args[1] ) ) {
    166                     if ( $args[1] === 'api-key' ) {
    167                         Helper::instawp_generate_api_key( $args[2] );
    168                     } elseif ( $args[1] === 'api-domain' ) {
    169                         Helper::set_api_domain( $args[2] );
    170                     }
     277   
     278                if ( ! empty( $payload['mode']['name'] ) ) {
     279                    $wp_config = new WPConfig( array( 'INSTAWP_CONNECT_MODE' => $payload['mode']['name'] ) );
     280                    $wp_config->set();
     281                   
     282                    WP_CLI::success( 'Mode configuration updated successfully' );
    171283                }
    172 
    173                 if ( isset( $args[3] ) ) {
    174                     $payload_decoded = base64_decode( $args[3] ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
    175                     $payload         = json_decode( $payload_decoded, true );
    176 
    177                     if ( isset( $payload['mode'] ) ) {
    178                         if ( isset( $payload['mode']['name'] ) ) {
    179                             try {
    180                                 $wp_config = new WPConfig( array( 'INSTAWP_CONNECT_MODE' => $payload['mode']['name'] ) );
    181                                 $wp_config->set();
    182                             } catch ( \Exception $e ) {
    183                                 WP_CLI::error( $e->getMessage() );
    184 
    185                                 return false;
    186                             }
    187                         }
    188                     }
    189                 }
    190 
    191                 return true;
    192             }
    193 
    194             if ( isset( $args[0] ) && $args[0] === 'config-remove' ) {
    195                 $option = new \InstaWP\Connect\Helpers\Option();
    196                 $option->delete( array( 'instawp_api_options', 'instawp_connect_id_options' ) );
    197 
    198                 return true;
    199             }
    200 
    201             if ( isset( $args[0] ) && $args[0] === 'hard-reset' ) {
    202                 instawp_reset_running_migration( 'hard', false );
    203 
    204                 if ( ! empty( $assoc_args['clear-events'] ) ) {
    205                     instawp_delete_sync_entries();
    206                 }
    207 
    208                 return true;
    209             }
    210 
    211             if ( isset( $args[0] ) && $args[0] === 'clear-events' ) {
    212                 instawp_delete_sync_entries();
    213 
    214                 return true;
    215             }
    216 
    217 
    218             if ( isset( $args[0] ) && $args[0] === 'activate-plan' ) {
    219                 $plan_id = isset( $args[1] ) ? intval( $args[1] ) : 0;
    220                 if ( ! $plan_id ) {
    221                     WP_CLI::error( esc_html__( 'Plan ID is required', 'instawp-connect' ) );
    222 
    223                     return false;
    224                 }
    225 
    226                 $response = instawp_connect_activate_plan( $plan_id );
    227                 if ( ! $response['success'] ) {
    228                     WP_CLI::error( $response['message'] );
    229 
    230                     return false;
    231                 }
    232 
    233                 return true;
    234             }
    235 
    236             if ( isset( $args[0] ) && $args[0] === 'refresh-staging-list' ) {
    237                 instawp_set_staging_sites_list();
    238 
    239                 return true;
    240             }
    241 
    242             if ( isset( $args[0] ) && $args[0] === 'staging-set' && ! empty( $args[1] ) ) {
    243                 Option::update_option( 'instawp_sync_connect_id', intval( $args[1] ) );
    244                 Option::update_option( 'instawp_is_staging', true );
    245                 instawp_get_source_site_detail();
    246 
    247                 return true;
    248             }
    249 
    250             if ( isset( $args[0] ) && $args[0] === 'reset' ) {
    251                 if ( isset( $args[1] ) && $args[1] === 'staging' ) {
    252                     delete_option( 'instawp_sync_connect_id' );
    253                     delete_option( 'instawp_is_staging' );
    254                     instawp_reset_running_migration();
    255                 }
    256             }
    257 
    258             if ( isset( $args[0] ) && $args[0] === 'scan' ) {
    259                 if ( isset( $args[1] ) && $args[1] === 'summary' ) {
    260                     $wp_scanner  = new \InstaWP\Connect\Helpers\WPScanner();
    261                     $summary_res = $wp_scanner->scan_summary();
    262 
    263                     if ( is_wp_error( $summary_res ) ) {
    264                         WP_CLI::error( $summary_res->get_error_message() );
    265 
    266                         return false;
    267                     }
    268 
    269                     if ( ! is_array( $summary_res ) ) {
    270                         WP_CLI::error( esc_html__( 'Failed: Could not create performance summary.', 'instawp-connect' ) );
    271 
    272                         return false;
    273                     }
    274 
    275                     WP_CLI::success( esc_html__( 'Performance Summary of this website is given below:', 'instawp-connect' ) );
    276 
    277                     $this->render_cli_from_array( $summary_res );
    278                 }
    279 
    280                 if ( isset( $args[1] ) && $args[1] === 'slow-item' ) {
    281                     $wp_scanner = new \InstaWP\Connect\Helpers\WPScanner();
    282                     $slow_items = $wp_scanner->scan_slow_items();
    283 
    284                     if ( is_wp_error( $slow_items ) ) {
    285                         WP_CLI::error( $slow_items->get_error_message() );
    286 
    287                         return false;
    288                     }
    289 
    290                     if ( ! is_array( $slow_items ) ) {
    291                         WP_CLI::error( esc_html__( 'Failed: Could not calculate slow items.', 'instawp-connect' ) );
    292 
    293                         return false;
    294                     }
    295 
    296                     $slow_items_table = array();
    297                     $counter          = 0;
    298                     $fields           = array( 'ID', 'Name', 'Type', 'Time Taken' );
    299 
    300                     foreach ( $slow_items as $slow_item ) {
    301                         ++ $counter;
    302                         $slow_items_table[] = array(
    303                             'ID'         => $counter,
    304                             'Name'       => $slow_item[2],
    305                             'Type'       => $slow_item[3],
    306                             'Time Taken' => $slow_item[1],
    307                         );
    308                     }
    309 
    310                     WP_CLI::success( esc_html__( 'Slow items of this website are given below: (Top is the slowest one)', 'instawp-connect' ) );
    311 
    312                     WP_CLI\Utils\format_items( 'table', $slow_items_table, $fields );
    313                 }
    314             }
    315 
    316             return true;
     284            } catch ( \Exception $e ) {
     285                WP_CLI::error( 'Failed to configure mode: ' . $e->getMessage() );
     286                return false;
     287            }
     288        }
     289       
     290        // Helper methods for scan functionality
     291        private function handle_scan_summary() {
     292            $wp_scanner = new WPScanner();
     293            $summary_res = $wp_scanner->scan_summary();
     294       
     295            if ( is_wp_error($summary_res) ) {
     296                WP_CLI::error($summary_res->get_error_message());
     297                return false;
     298            }
     299       
     300            if ( ! is_array($summary_res) ) {
     301                WP_CLI::error(__('Failed: Could not create performance summary.', 'instawp-connect'));
     302                return false;
     303            }
     304       
     305            WP_CLI::success(__('Performance Summary of this website is given below:', 'instawp-connect'));
     306            $this->render_cli_from_array($summary_res);
     307        }
     308       
     309        private function handle_scan_slow_items() {
     310            $wp_scanner = new WPScanner();
     311            $slow_items = $wp_scanner->scan_slow_items();
     312       
     313            if ( is_wp_error( $slow_items ) || ! is_array( $slow_items ) ) {
     314                WP_CLI::error( __( 'Failed: Could not calculate slow items.', 'instawp-connect' ) );
     315                return false;
     316            }
     317       
     318            $slow_items_table = array_map( function( $item, $index ) {
     319                return array(
     320                    'ID'         => $index + 1,
     321                    'Name'       => $item[2],
     322                    'Type'       => $item[3],
     323                    'Time Taken' => $item[1],
     324                );
     325            }, $slow_items, array_keys( $slow_items ) );
     326       
     327            WP_CLI::success( __( 'Slow items of this website are given below: (Top is the slowest one)', 'instawp-connect' ) );
     328            WP_CLI\Utils\format_items( 'table', $slow_items_table, array( 'ID', 'Name', 'Type', 'Time Taken' ) );
    317329        }
    318330
  • instawp-connect/trunk/includes/class-instawp-tools.php

    r3216309 r3218292  
    358358            $migrate_settings['excluded_paths'][] = 'wp-includes';
    359359            $migrate_settings['excluded_paths'][] = 'wp-cli.yml';
    360 //          $migrate_settings['excluded_paths'][] = 'index.php';
    361 //          $migrate_settings['excluded_paths'][] = 'wp-load.php';
    362 //          $migrate_settings['excluded_paths'][] = 'wp-activate.php';
    363 //          $migrate_settings['excluded_paths'][] = 'wp-blog-header.php';
    364 //          $migrate_settings['excluded_paths'][] = 'wp-comments-post.php';
    365 //          $migrate_settings['excluded_paths'][] = 'wp-config-sample.php';
    366 //          $migrate_settings['excluded_paths'][] = 'wp-cron.php';
    367 //          $migrate_settings['excluded_paths'][] = 'wp-links-opml.php';
    368 //          $migrate_settings['excluded_paths'][] = 'wp-login.php';
    369 //          $migrate_settings['excluded_paths'][] = 'wp-mail.php';
    370 //          $migrate_settings['excluded_paths'][] = 'wp-settings.php';
    371 //          $migrate_settings['excluded_paths'][] = 'wp-signup.php';
    372 //          $migrate_settings['excluded_paths'][] = 'wp-trackback.php';
     360//          $migrate_settings['excluded_paths'][] = 'index.php';
     361//          $migrate_settings['excluded_paths'][] = 'wp-load.php';
     362//          $migrate_settings['excluded_paths'][] = 'wp-activate.php';
     363//          $migrate_settings['excluded_paths'][] = 'wp-blog-header.php';
     364//          $migrate_settings['excluded_paths'][] = 'wp-comments-post.php';
     365//          $migrate_settings['excluded_paths'][] = 'wp-config-sample.php';
     366//          $migrate_settings['excluded_paths'][] = 'wp-cron.php';
     367//          $migrate_settings['excluded_paths'][] = 'wp-links-opml.php';
     368//          $migrate_settings['excluded_paths'][] = 'wp-login.php';
     369//          $migrate_settings['excluded_paths'][] = 'wp-mail.php';
     370//          $migrate_settings['excluded_paths'][] = 'wp-settings.php';
     371//          $migrate_settings['excluded_paths'][] = 'wp-signup.php';
     372//          $migrate_settings['excluded_paths'][] = 'wp-trackback.php';
    373373            $migrate_settings['excluded_paths'][] = 'xmlrpc.php';
    374374            $migrate_settings['excluded_paths'][] = '.ftpquota';
     
    379379            $migrate_settings['excluded_paths'][] = 'robots.txt';
    380380
    381 //          if ( empty( $migrate_settings['mode'] ) || 'pull' == $migrate_settings['mode'] ) {
    382 //              $migrate_settings['excluded_paths'][] = $wp_root_dir . '/wp-config.php';
    383 //          }
     381//          if ( empty( $migrate_settings['mode'] ) || 'pull' == $migrate_settings['mode'] ) {
     382//              $migrate_settings['excluded_paths'][] = $wp_root_dir . '/wp-config.php';
     383//          }
    384384        }
    385385
     
    10531053        $excluded_tables_rows = Helper::get_args_option( 'excluded_tables_rows', $migrate_settings, array() );
    10541054
    1055         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_api_options';
    1056         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_connect_id_options';
    1057         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_sync_parent_connect_data';
    1058         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_migration_details';
    1059         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_last_migration_details';
    1060         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_api_key_config_completed';
    1061         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_is_event_syncing';
    1062         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_staging_sites';
    1063         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:instawp_is_staging';
    1064         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:schema-ActionScheduler_StoreSchema';
    1065         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:schema-ActionScheduler_LoggerSchema';
    1066         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:action_scheduler_hybrid_store_demarkation';
    1067         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:_transient_timeout_action_scheduler_last_pastdue_actions_check';
    1068         $excluded_tables_rows["{$wpdb->prefix}options"][] = 'option_name:_transient_action_scheduler_last_pastdue_actions_check';
     1055        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_api_options';
     1056        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_connect_id_options';
     1057        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_sync_parent_connect_data';
     1058        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_migration_details';
     1059        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_last_migration_details';
     1060        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_api_key_config_completed';
     1061        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_is_event_syncing';
     1062        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_staging_sites';
     1063        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:instawp_is_staging';
     1064        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:schema-ActionScheduler_StoreSchema';
     1065        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:schema-ActionScheduler_LoggerSchema';
     1066        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:action_scheduler_hybrid_store_demarkation';
     1067        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:_transient_timeout_action_scheduler_last_pastdue_actions_check';
     1068        $excluded_tables_rows[ "{$wpdb->prefix}options" ][] = 'option_name:_transient_action_scheduler_last_pastdue_actions_check';
    10691069
    10701070        $migrate_settings['excluded_tables_rows'] = $excluded_tables_rows;
    10711071
     1072        $migrate_settings['source_ip_address'] = self::get_user_ip_address();
     1073
    10721074        return self::process_migration_settings( $migrate_settings );
     1075    }
     1076
     1077    public static function get_user_ip_address() {
     1078        // Check for IPv6 and IPv4 validation
     1079        $ip_pattern = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^(?:(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:))$/';
     1080
     1081        // Array of possible IP address server variables
     1082        $ip_sources = array(
     1083            'HTTP_CLIENT_IP',
     1084            'HTTP_X_FORWARDED_FOR',
     1085            'HTTP_X_FORWARDED',
     1086            'HTTP_X_CLUSTER_CLIENT_IP',
     1087            'HTTP_FORWARDED_FOR',
     1088            'HTTP_FORWARDED',
     1089            'REMOTE_ADDR',
     1090        );
     1091
     1092        // Loop through possible IP sources
     1093        foreach ( $ip_sources as $source ) {
     1094            if ( isset( $_SERVER[ $source ] ) ) {
     1095                $ip = $_SERVER[ $source ];
     1096
     1097                // Handle X-Forwarded-For header which may contain multiple IPs
     1098                if ( $source === 'HTTP_X_FORWARDED_FOR' ) {
     1099                    $ips = explode( ',', $ip );
     1100                    $ip  = trim( $ips[0] ); // Get the first IP in the list
     1101                }
     1102
     1103                // Validate IP format
     1104                if ( filter_var( $ip, FILTER_VALIDATE_IP ) && preg_match( $ip_pattern, $ip ) ) {
     1105                    return $ip;
     1106                }
     1107            }
     1108        }
     1109
     1110        // If no valid IP is found, return a fallback
     1111        return '0.0.0.0';
    10731112    }
    10741113
  • instawp-connect/trunk/instawp-connect.php

    r3216309 r3218292  
    88 * Plugin Name:       InstaWP Connect
    99 * Description:       1-click WordPress plugin for Staging, Migrations, Management, Sync and Companion plugin for InstaWP.
    10  * Version:           0.1.0.74
     10 * Version:           0.1.0.75
    1111 * Author:            InstaWP Team
    1212 * Author URI:        https://instawp.com/
     
    2828global $wpdb;
    2929
    30 defined( 'INSTAWP_PLUGIN_VERSION' ) || define( 'INSTAWP_PLUGIN_VERSION', '0.1.0.74' );
     30defined( 'INSTAWP_PLUGIN_VERSION' ) || define( 'INSTAWP_PLUGIN_VERSION', '0.1.0.75' );
    3131defined( 'INSTAWP_API_DOMAIN_PROD' ) || define( 'INSTAWP_API_DOMAIN_PROD', 'https://app.instawp.io' );
    3232
  • instawp-connect/trunk/migrate/templates/main.php

    r3216309 r3218292  
    5555                <div class="flex justify-between items-center transition-all duration-300">
    5656                    <p class="max-w-[85%]">
    57                         <span class="inline-block"><?php printf( wp_kses_post( __( 'A new version of InstaWP Connect (%s) is available. You are using an older version (%s), it is recommended to update.', 'instawp-connect' ) ), $new_version_number, INSTAWP_PLUGIN_VERSION ); ?></span>
     57                        <span class="inline-block"><?php printf( wp_kses_post( __( 'A new version of InstaWP Connect (%1$s) is available. You are using an older version (%2$s), it is recommended to update.', 'instawp-connect' ) ), $new_version_number, INSTAWP_PLUGIN_VERSION ); ?></span>
    5858                        <span class="instawp-update-notice hidden bg-red-700 text-gray-200 px-1.5 py-[2px] mt-2 rounded-sm transition-all duration-300"><?php esc_html_e( 'Could not update the plugin!', 'instawp-connect' ); ?></span>
    5959                    </p>
  • instawp-connect/trunk/readme.txt

    r3216309 r3218292  
    55Tested up to: 6.7
    66Requires PHP: 7.0
    7 Stable tag: 0.1.0.74
     7Stable tag: 0.1.0.75
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    9999== Changelog ==
    100100
     101= 0.1.0.75 - 07 January 2025 =
     102- FIX: Added changes to directly connect to the advanced plan.
     103- FIX: Added changes to create connect as unmanaged.
     104- FIX: Fixed pull migration issue.
     105
    101106= 0.1.0.74 - 03 January 2025 =
    102107- NEW: Show warning message if the plugin is not on latest version.
  • instawp-connect/trunk/uninstall.php

    r3216309 r3218292  
    77    exit;
    88}
     9
     10global $wpdb;
    911
    1012defined( 'INSTAWP_DEFAULT_BACKUP_DIR' ) || define( 'INSTAWP_DEFAULT_BACKUP_DIR', 'instawpbackups' );
     
    2931$api_key     = isset( $api_options['api_key'] ) ? $api_options['api_key'] : '';
    3032$api_url     = isset( $api_options['api_url'] ) ? $api_options['api_url'] : 'https://app.instawp.io';
     33$site_url    = $wpdb->get_var( "SELECT option_value FROM {$wpdb->options} WHERE option_name = 'siteurl'" );
     34$site_url    = empty( $site_url ) ? site_url() : $site_url;
    3135
    3236if ( ! empty( $connect_id ) && ! empty( $api_key ) ) {
     
    3640            'Accept'        => 'application/json',
    3741            'Content-Type'  => 'application/json',
    38             'Referer'       => Helper::wp_site_url(),
     42            'Referer'       => $site_url,
    3943        ),
    4044        'timeout'         => 60,
  • instawp-connect/trunk/vendor/composer/installed.json

    r3216309 r3218292  
    88                "type": "git",
    99                "url": "https://github.com/InstaWP/connect-helpers.git",
    10                 "reference": "242319c9434567c10b83f52881d0616ce76044fc"
    11             },
    12             "dist": {
    13                 "type": "zip",
    14                 "url": "https://api.github.com/repos/InstaWP/connect-helpers/zipball/242319c9434567c10b83f52881d0616ce76044fc",
    15                 "reference": "242319c9434567c10b83f52881d0616ce76044fc",
     10                "reference": "4e5a060b35cdcc903ee2165e1cb5b2794437cf74"
     11            },
     12            "dist": {
     13                "type": "zip",
     14                "url": "https://api.github.com/repos/InstaWP/connect-helpers/zipball/4e5a060b35cdcc903ee2165e1cb5b2794437cf74",
     15                "reference": "4e5a060b35cdcc903ee2165e1cb5b2794437cf74",
    1616                "shasum": ""
    1717            },
     
    2020                "wp-cli/wp-config-transformer": "^1.3"
    2121            },
    22             "time": "2024-12-27T13:37:12+00:00",
     22            "time": "2025-01-02T11:30:59+00:00",
    2323            "default-branch": true,
    2424            "type": "library",
  • instawp-connect/trunk/vendor/composer/installed.php

    r3216309 r3218292  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '82b751d64e44a714d57e71807bcf2c5969ee7876',
     6        'reference' => '5e2939ad37db1d19f4609420ae51403a96362415',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '82b751d64e44a714d57e71807bcf2c5969ee7876',
     16            'reference' => '5e2939ad37db1d19f4609420ae51403a96362415',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
     
    2323            'pretty_version' => 'dev-main',
    2424            'version' => 'dev-main',
    25             'reference' => '242319c9434567c10b83f52881d0616ce76044fc',
     25            'reference' => '4e5a060b35cdcc903ee2165e1cb5b2794437cf74',
    2626            'type' => 'library',
    2727            'install_path' => __DIR__ . '/../instawp/connect-helpers',
  • instawp-connect/trunk/vendor/instawp/connect-helpers/src/Helper.php

    r3216309 r3218292  
    55class Helper {
    66
    7     public static function instawp_generate_api_key( $api_key, $jwt = '' ) {
    8         return self::generate_api_key( $api_key, $jwt );
    9     }
    10 
    11     public static function generate_api_key( $api_key, $jwt = '' ) {
     7    public static function instawp_generate_api_key( $api_key, $jwt = '', $managed = true ) {
     8        return self::generate_api_key( $api_key, $jwt, $managed );
     9    }
     10
     11    public static function generate_api_key( $api_key, $jwt = '', $managed = true ) {
    1212        if ( empty( $api_key ) ) {
    1313            error_log( 'instawp_generate_api_key empty api_key parameter' );
     
    4343            'username'       => base64_encode( self::get_admin_username() ),
    4444            'plan_id'        => self::get_connect_plan_id(),
     45            'managed'        => $managed,
    4546        );
    4647        $connect_response = Curl::do_curl( 'connects', $connect_body, array(), 'POST', 'v1' );
Note: See TracChangeset for help on using the changeset viewer.