Plugin Directory

Changeset 1961287


Ignore:
Timestamp:
10/23/2018 11:47:00 AM (7 years ago)
Author:
appeto
Message:

3.0.0

  • Add multi site (network) for woocommerce
Location:
appeto-woocommerce
Files:
121 added
5 edited

Legend:

Unmodified
Added
Removed
  • appeto-woocommerce/trunk/api/api.php

    r1751958 r1961287  
    3030                $plugins = get_option('active_plugins');
    3131                if(in_array("woocommerce/woocommerce.php", $plugins)) {
     32                    $is_hard = false;
     33                    if(function_exists("mcrypt_encrypt")) {
     34                        $is_hard = true;
     35                    }
    3236                    $result = array(
    3337                        "status" => "ok",
    34                         "currency_symbol" => get_woocommerce_currency_symbol()
     38                        "currency_symbol" => get_woocommerce_currency_symbol(),
     39                        "is_hard" => $is_hard
    3540                    );
    3641                }
     42                if(function_exists("is_plugin_active_for_network")) {
     43                    if ( is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) {
     44                        $is_hard = false;
     45                        if(function_exists("mcrypt_encrypt")) {
     46                            $is_hard = true;
     47                        }
     48                        $result = array(
     49                            "status" => "ok",
     50                            "currency_symbol" => get_woocommerce_currency_symbol(),
     51                            "is_hard" => $is_hard
     52                        );
     53                    }
     54                }
    3755                self::jsonView($result);
     56            }
     57
     58            if(isset($_GET["check_api"]) and $_GET["check_api"] == "network") {
     59                $result = appeto_get_network_sites();
     60                self::jsonView($result);
     61            }
     62
     63            if(isset($_GET["check_api"]) and $_GET["check_api"] == "networkSearch" and isset($_GET["s"]) and $_GET["s"] != "") {
     64                global $wpdb;
     65                $result = array();
     66                if(function_exists('get_sites')) {
     67                    $sites = get_sites();
     68                }
     69                elseif(function_exists('wp_get_sites')) {
     70                    $sites = wp_get_sites();
     71                }
     72                else {
     73                    $sites = array();
     74                }
     75                $q = esc_sql($_GET["s"]);
     76                foreach($sites as $site) {
     77                    if ($site->path == "/") continue;
     78                    $bimage = get_option("appeto_ntsite_img_".$site->blog_id, "");
     79                    switch_to_blog($site->blog_id);
     80                    $posts = $wpdb->get_blog_prefix($site->blog_id)."posts";
     81                    $wp_postmeta = $wpdb->get_blog_prefix($site->blog_id)."postmeta";
     82                    $select = "SELECT p.id, p.post_title AS title, m.meta_value AS regular_price, pt.meta_value AS price FROM {$posts} p
     83                            INNER JOIN {$wp_postmeta} m ON (
     84                                 p.id = m.post_id
     85                            )
     86                            INNER JOIN {$wp_postmeta} pt ON (
     87                                 p.id = pt.post_id
     88                            )
     89                            WHERE
     90                             p.post_type = 'product'
     91                             AND
     92                            p.post_title LIKE '%".$q."%'
     93                            AND
     94                             p.post_status = 'publish'
     95                            AND
     96                             m.meta_key = '_regular_price'
     97                            AND
     98                             pt.meta_key = '_price'";
     99                    $_r = $wpdb->get_results($select);
     100                    if(!empty($_r)) {
     101                        foreach ( $_r as $k => $post )
     102                        {
     103                            $image_url = get_the_post_thumbnail_url( $post->id );
     104                            if($image_url == "") {
     105                                $image_url = wc_placeholder_img_src();
     106                            }
     107                            $_r[$k]->img = $image_url;
     108                            $_r[$k]->site = $site->blog_id;
     109                        }
     110                        $result[$site->blog_id]["result"] = $_r;
     111                        $blog_details = get_blog_details( array( 'blog_id' => $site->blog_id ) );
     112                        $r["id"] = $site->blog_id;
     113                        $r["applink"] = base64_encode(json_encode(array("id" => $site->blog_id, "path" => $blog_details->path, "siteurl" => $blog_details->siteurl)));
     114                        $r["name"] = $blog_details->blogname;
     115                        $r["path"] = $blog_details->path;
     116                        $r["siteurl"] = $blog_details->siteurl;
     117                        $r["image"] = $bimage;
     118                        $result[$site->blog_id]["info"] = $r;
     119                    }
     120                    restore_current_blog();
     121                }
     122                self::jsonView($result);
     123                exit;
    38124            }
    39125
     
    416502    private static function decode_this_key( $txt, $hashKey )
    417503    {
    418         return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($hashKey), base64_decode( $txt ), MCRYPT_MODE_CBC, md5(md5($hashKey))), "\0");
    419     }
     504        if(function_exists("mcrypt_encrypt")) {
     505            return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($hashKey), base64_decode( $txt ), MCRYPT_MODE_CBC, md5(md5($hashKey))), "\0");
     506        }
     507        return base64_decode( $txt );
     508    }
     509
    420510}
    421511
  • appeto-woocommerce/trunk/api/views/v2/product.php

    r1709968 r1961287  
     1<?php
     2if(isset($extra->network) and $extra->network > 0) {
     3    $current_blog_details = get_blog_details( array( 'blog_id' => $extra->network ) );
     4    $blog_id = $extra->network;
     5    $ck = get_option("appeto_ck_".$blog_id, "");
     6    $cs = get_option("appeto_cs_".$blog_id, "");
     7    $localCk = get_option("appeto_localCk_".$blog_id, "");
     8    $localCs = get_option("appeto_localCs_".$blog_id, "");
     9    $woocommerce_api = $current_blog_details->siteurl."/";
     10    $currency = get_woocommerce_currency_symbol();
     11    $hashKey = get_option('appeto_secure_key_woo');
     12    $ck = base64_encode(appeto_encode_this_key($ck, $hashKey));
     13    $cs = base64_encode(appeto_encode_this_key($cs, $hashKey));
     14}
     15?>
    116<ion-view title="<?php echo $extra->name ?>" cache-view="false">
    217    <ion-content padding="false" ng-controller="WoocommerceProductCtrl" class="<?php echo $extra->content_classes." ".$extra->layout;?>"
     
    520             layout='<?php echo $extra->layout?>';
    621             currency_symbol='<?php echo get_woocommerce_currency_symbol();?>';
    7              productId='<?php echo $extra->id?>';"
     22             <?php
     23             if(isset($extra->network) and $extra->network > 0) {
     24                 echo " fromNetwork=true; localCk='{$localCk}'; localCs='{$localCs}'; ck='{$ck}'; cs='{$cs}'; ";
     25             }
     26             ?>
     27             productId='<?php echo $extra->id?>';
     28             "
    829             >
    930        <ion-slide-box ng-if="product.images.length > 0" class="product-thumb-slider" auto-play="true" show-pager="true">
  • appeto-woocommerce/trunk/controllers/menu.php

    r1751958 r1961287  
    1414    }
    1515
     16    static function networkWoo() {
     17        $path = plugin_dir_path(dirname(__FILE__));
     18        include($path.'views/wooNetwork.php');
     19    }
     20
    1621    static function auth()
    1722    {
     
    2126
    2227    static function appetoWooPage() {
    23         wp_redirect("admin.php?page=wc-settings&tab=settings_tab_appeto");
     28        appeto_change_location("admin.php?page=wc-settings&tab=settings_tab_appeto");
    2429    }
    2530    static function appetoJsonApi() {
    26         wp_redirect("options-general.php?page=json-api");
     31        appeto_change_location("options-general.php?page=json-api");
    2732    }
    2833    static function appetoWpCors() {
    29         wp_redirect("options-general.php?page=wp-cors");
     34        appeto_change_location("options-general.php?page=wp-cors");
    3035    }
    3136
     
    8388            'appeto_admin_menu::appetoWpCors' // clicking callback function
    8489        );
     90        add_submenu_page(
     91            'appeto/controllers/menu.php', // Menu page to attach to #options-general.php
     92            'ووکامرس شبکه ای',
     93            'ووکامرس شبکه ای',
     94            'manage_options', // permissions
     95            'appeto-network-woo', // page-name (used in the URL)
     96            'appeto_admin_menu::networkWoo' // clicking callback function
     97        );
    8598    }
    8699}
  • appeto-woocommerce/trunk/index.php

    r1751958 r1961287  
    317317}
    318318
     319function appeto_change_location($url) {
     320    if(!headers_sent()) {
     321        header("Location: ".$url);
     322    }
     323    else {
     324        echo '<script>document.location.href = "'.$url.'";</script>';
     325    }
     326    exit;
     327}
     328
    319329/* Login/register */
    320330new appeto_auth();
     331/* woocommrece network */
     332function appeto_get_network_sites() {
     333    $result = array();
     334    if(function_exists('get_sites')) {
     335        $sites = get_sites();
     336    }
     337    elseif(function_exists('wp_get_sites')) {
     338        $sites = wp_get_sites();
     339    }
     340    else {
     341        $sites = array();
     342    }
     343    foreach($sites as $site) {
     344        if($site->path == "/") continue;
     345        $blog_details = get_blog_details( array( 'blog_id' => $site->blog_id ) );
     346        $r["id"] = $site->blog_id;
     347        $r["applink"] = base64_encode(json_encode(array("id" => $site->blog_id, "path" => $blog_details->path, "siteurl" => $blog_details->siteurl)));
     348        $r["name"] = $blog_details->blogname;
     349        $r["path"] = $blog_details->path;
     350        $r["siteurl"] = $blog_details->siteurl;
     351        $r["image"] = get_option("appeto_ntsite_img_".$site->blog_id, "");
     352        array_push($result, $r);
     353    }
     354    return $result;
     355}
     356
     357function appeto_encode_this_key( $txt, $hashKey )
     358{
     359    if(function_exists("mcrypt_encrypt")) {
     360        return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($hashKey), $txt, MCRYPT_MODE_CBC, md5(md5($hashKey))));
     361    }
     362    return base64_encode($txt);
     363}
  • appeto-woocommerce/trunk/readme.txt

    r1751958 r1961287  
    22Contributors: appeto
    33Tags: app, appeto, api, persian app generator, app generator, woocommerce, shop, woocommerce android, woocommerce ios, woocommerce mobile
    4 Requires at least: 3.0.1
     4Requires at least: 4
    55Tested up to: 4
    6 Stable tag: 4.8.1
     6Stable tag: 4.9.8
    77License: appeto.ir users
    88
     
    6868= 2.2.0 =
    6969* Add login and register from application
     70
     71= 3.0.0 =
     72* Add multi site (network) for woocommerce
Note: See TracChangeset for help on using the changeset viewer.