Plugin Directory

Changeset 3463813


Ignore:
Timestamp:
02/17/2026 08:28:28 PM (7 weeks ago)
Author:
stacks
Message:

Version 7.0: Security fix - removed all old tags with admin escalation vulnerability. Complete plugin rewrite with token-based REST API authentication.

Location:
stacks-mobile-app-builder
Files:
20 added
30 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • stacks-mobile-app-builder/trunk/index.php

    r2958799 r3463813  
    33/*
    44 * Plugin Name: Stacks Mobile App Builder
     5 * Plugin URI: https://stacksmarket.co
    56 * Author: Stacks
    6  * Author URI: stacksmarket.co
    7  * Description: Enjoy the fast and easy experience of building your Ecommerce mobile application
    8  * Version: 5.2.3
     7 * Author URI: https://stacksmarket.co
     8 * Description: Enjoy the fast and easy experience of building your Ecommerce mobile application.
     9 * Version: 7.0
     10 * Requires at least: 5.8
     11 * Requires PHP: 7.4
     12 * License: GPL-2.0-or-later
     13 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     14 * Text Domain: stacks-mobile-app-builder
    915 */
    10 class stacks_app_builder {
     16if ( ! defined( 'ABSPATH' ) ) {
     17    exit; // Exit if accessed directly.
     18}
     19
     20class Stacks_App_Builder_V7 {
    1121
    1222    public function __construct() {
    1323        add_action('after_setup_theme', array($this, 'initialize'));
    14 
    15         add_action( 'admin_menu', array( &$this, 'stacks_admin_menu' ) );
    16 
    17         add_action('admin_enqueue_scripts', array( &$this, 'stacks_admin_enqueue_scripts') );
    18 
     24        add_action( 'admin_menu', array( $this, 'stacks_admin_menu' ) );
     25        add_action('admin_enqueue_scripts', array( $this, 'stacks_admin_enqueue_scripts') );
    1926        register_activation_hook(__FILE__, array($this, 'stacks_app_activate'));
    20 
    2127    }
    2228
    2329    public function initialize() {
    24         require_once 'helper_functions.php';
    25         require_once 'api/main.php';
    26         require_once 'modules/main.php';
     30        $this->definitions();
     31        require_once plugin_dir_path( __FILE__ ) . 'api/categories.php';
     32        require_once plugin_dir_path( __FILE__ ) . 'api/orders.php';
     33        require_once plugin_dir_path( __FILE__ ) . 'api/products.php';
     34        require_once plugin_dir_path( __FILE__ ) . 'api/users.php';
     35    }
     36
     37    public function definitions() {
     38        if ( ! defined( 'STACKS_APP_VERSION' ) ) {
     39            define('STACKS_APP_VERSION', '7.0');
     40        }
     41        if ( ! defined( 'STACKS_API' ) ) {
     42            define('STACKS_API', 'https://builder.stacksmarket.co/wp-json/v4/');
     43        }
    2744    }
    2845
    2946    /**
    30      * Make sure that there is no old versions of Stacks Plugin that is active, this should prevent conflicts
     47     * Make sure that there is no old versions of Stacks Plugin that is active.
    3148     *
    32      * @param [type] $plugin
    3349     * @return void
    3450     */
    3551    public function stacks_app_activate() {
     52        if ( ! function_exists( 'get_plugins' ) ) {
     53            require_once ABSPATH . 'wp-admin/includes/plugin.php';
     54        }
    3655        $all_plugins = get_plugins();
    3756        foreach ($all_plugins as $key => $value) {
    38             if($value['Name'] == 'Stacks App') {
     57            if($value['Name'] === 'Stacks App') {
    3958                if(is_plugin_active($key)) {
    4059                    deactivate_plugins( $key );
     
    4261            }
    4362        }
    44 
    4563        flush_rewrite_rules();
    4664    }
    4765
    48     // adds stacks menu item to wordpress admin dashboard
    49     function stacks_admin_menu() {
    50         add_menu_page( __( 'Stacks Dashboard' ),
    51         __( 'Stacks' ),
    52         'manage_options',
    53         'stacks-welcome',
    54         array( &$this, 'stacks_admin_menu_page' ), plugin_dir_url( __FILE__ ) . '/assets/images/favicon.png'
     66    /**
     67     * Adds stacks menu item to wordpress admin dashboard.
     68     */
     69    public function stacks_admin_menu() {
     70        add_action('admin_init', array( $this, 'stacks_register_settings' ));
     71
     72        add_menu_page(
     73            __( 'Stacks Dashboard', 'stacks-mobile-app-builder' ),
     74            __( 'Stacks', 'stacks-mobile-app-builder' ),
     75            'manage_options',
     76            'stacks-welcome-v7',
     77            array( $this, 'stacks_admin_menu_page' ),
     78            plugin_dir_url( __FILE__ ) . 'assets/images/favicon.png'
    5579        );
    56        
     80
     81        add_submenu_page(
     82            'stacks-welcome-v7',
     83            __( 'Stacks Settings', 'stacks-mobile-app-builder' ),
     84            __( 'Settings', 'stacks-mobile-app-builder' ),
     85            'manage_options',
     86            'stacks-settings',
     87            array($this, 'render_stacks_settings_page')
     88        );
     89    }
     90
     91    /**
     92     * Register plugin settings.
     93     */
     94    public function stacks_register_settings() {
     95        register_setting('stacks_settings_group', 'stacks_token', array(
     96            'type' => 'string',
     97            'sanitize_callback' => 'sanitize_text_field',
     98        ));
     99        register_setting('stacks_settings_group', 'stacks_project', array(
     100            'type' => 'string',
     101            'sanitize_callback' => 'sanitize_text_field',
     102        ));
    57103    }
    58104
    59105    public function stacks_admin_menu_page() {
    60         // Load home page
    61         require_once untrailingslashit( __DIR__ ) . '/views/stacks-welcome.php';
     106        require_once plugin_dir_path( __FILE__ ) . 'views/stacks-welcome-v7.php';
    62107    }
    63108
    64109    public function stacks_admin_enqueue_scripts(){
    65                
    66         $current_page = get_current_screen()->base;
    67        
    68         wp_enqueue_style( 'stacks_main_css', plugins_url('assets/css/stacks-main.css', __FILE__), array());
     110        wp_enqueue_style(
     111            'stacks_main_css',
     112            plugin_dir_url( __FILE__ ) . 'assets/css/stacks-main.css',
     113            array(),
     114            STACKS_APP_VERSION
     115        );
     116    }
    69117
     118    public function render_stacks_settings_page() {
     119        if ( ! current_user_can( 'manage_options' ) ) {
     120            return;
     121        }
     122        $stacks_token = esc_attr( get_option( 'stacks_token', '' ) );
     123        $stacks_project = esc_attr( get_option( 'stacks_project', '' ) );
     124        ?>
     125        <div class="wrap">
     126            <h1><?php esc_html_e( 'Stacks Settings', 'stacks-mobile-app-builder' ); ?></h1>
     127            <form method="post" action="options.php">
     128                <?php
     129                settings_fields('stacks_settings_group');
     130                do_settings_sections('stacks_settings_group');
     131                ?>
     132                <table class="form-table">
     133                    <tr>
     134                        <th scope="row">
     135                            <label for="stacksTokenInput"><?php esc_html_e( 'Stacks Token', 'stacks-mobile-app-builder' ); ?></label>
     136                        </th>
     137                        <td>
     138                            <input type="text"
     139                                id="stacksTokenInput"
     140                                name="stacks_token"
     141                                value="<?php echo esc_attr( $stacks_token ); ?>"
     142                                placeholder="<?php esc_attr_e( 'Your Stacks Token', 'stacks-mobile-app-builder' ); ?>"
     143                                class="regular-text">
     144                        </td>
     145                    </tr>
     146                    <tr>
     147                        <th scope="row">
     148                            <label for="stacksProjectInput"><?php esc_html_e( 'Project ID', 'stacks-mobile-app-builder' ); ?></label>
     149                        </th>
     150                        <td>
     151                            <input type="text"
     152                                id="stacksProjectInput"
     153                                name="stacks_project"
     154                                value="<?php echo esc_attr( $stacks_project ); ?>"
     155                                placeholder="<?php esc_attr_e( 'Your Stacks Project ID', 'stacks-mobile-app-builder' ); ?>"
     156                                class="regular-text">
     157                        </td>
     158                    </tr>
     159                </table>
     160                <?php submit_button( __( 'Save Settings', 'stacks-mobile-app-builder' ) ); ?>
     161            </form>
     162        </div>
     163        <?php
    70164    }
    71165
    72166}
    73167
    74 new stacks_app_builder();
     168new Stacks_App_Builder_V7();
  • stacks-mobile-app-builder/trunk/readme.txt

    r3225082 r3463813  
    66Requires PHP: 7.4
    77WC tested up to: 9.5.2
    8 Stable tag: 6.5.1
     8Stable tag: 7.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    121121
    122122== Changelog ==
     123
     124= Version 7.0 =
     125
     126Features
     127
     128* Complete plugin rewrite with improved security
     129* Token-based REST API authentication for all endpoints
     130* Proper WordPress coding standards compliance
     131* WordPress Filesystem API for image handling
     132* Two-way sync for products, categories, and orders with Stacks platform
     133* Auth0 user migration support
     134* Settings page for Stacks token and project configuration
    123135
    124136= Version 6.5.1 (19-1-2025) =
Note: See TracChangeset for help on using the changeset viewer.