Plugin Directory

Changeset 1957871


Ignore:
Timestamp:
10/17/2018 06:57:15 AM (7 years ago)
Author:
AmitDeyUS
Message:

2.1.6 Release

Location:
marketpowerwp
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • marketpowerwp/tags/2.1.6/config/replication_settings.json

    r1445352 r1957871  
    1515    "key": "default_multisoft_mpp_check_site_name_query_format",
    1616    "value": "hashKey=%s&siteName=%s"
     17  },
     18  {
     19    "key": "default_replicated_site_name",
     20    "value": "admin"
    1721  }
    1822]
  • marketpowerwp/tags/2.1.6/leplugin.php

    r1584743 r1957871  
    33/**
    44 * Plugin Name: Multisoft MarketPowerPRO Tools
    5  * Description: Integration of Market Power Pro to wordpress
    6  * Version: 2.1.4
    7  * Author: Rodine Mark Paul L. Villar, Dexter John Campos
    8  * Author URI: mailto:dean.villar@gmail.com?subject= Multisoft MPP Tools
     5 * Description: Integration of MarketPowerPro to Wordpress
     6 * Version: 2.1.6
     7 * Author: Rodine Mark Paul L. Villar
     8 * Author URI: mailto:dine@multisoft.com?subject=Multisoft+MarketPowerPRO+Tools
    99 */
    1010define('MPP_DEBUG', false || WP_DEBUG);
     
    1313    require ABSPATH . 'wp-admin/includes/plugin.php';
    1414}
     15
     16require 'plugin-update-checker/plugin-update-checker.php';
     17Puc_v4_Factory::buildUpdateChecker(
     18    'https://s3.amazonaws.com/multisoft-wordpress/plugins/marketpowerwp/release.json',
     19    __FILE__,
     20    'marketpowerwp'
     21);
     22
    1523include_once 'autoloader.php';
    1624
     
    6573);
    6674
    67 if (is_admin()) {
     75/*if (is_admin()) {
    6876    $multisoft_config_file = $multisoft_dirname . '/config/distributor_settings.json';
    6977    $multisoft_config = null;
     
    102110    $multisoft_pluginname,
    103111    $multisoft_config
    104 );
     112);*/
    105113unset(
    106114    $multisoft_dirname,
  • marketpowerwp/tags/2.1.6/readme.txt

    r1584743 r1957871  
    1 === MarketPowerWP ===
    2 Contributors: dean.villar@gmail.com
     1=== MarketPowerWP ===
     2Contributors: dine@multisoft.com
    33Tags: marketpowerpro, multisoft
    44Requires at least: 3.4+
    5 Stable tag: 2.1.4
     5Stable tag: 2.1.6
    66License: Commercial
    77
     
    8686</div>
    8787
    88  
    8988
    9089 [1]: http://www.marketpowerpro.com "f"
     
    9493[youtube https://www.youtube.com/watch?v=BkHmPWjUt4M]
    9594
    96 1. Add the plugin to your wordpress site.
     951. Install and activate the plugin to your wordpress site.
    9796
    98 2. Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
     972. Go to the MarketPowerPRO > Settings menu in your wordpress admin.
    9998
    100 3. Login to your administrator page yourwordpressblog.com/wp-admin.
     993. Set your Base MarketPowerPRO Web address, where your MarketPowerPRO system is located.
    101100
    102 4. Go to MarketPowerPRO.
     1014. Contact a MarketPowerPRO technical assistant to know your applicationID and set it to the applicationID field.
    103102
    104 5. Set your Base MPPE Web address, where your MarketPowerPRO system is located.
     1035. Set (or empty) a default replicated site name to be used in case none was provided in the URL (the default is "admin")
    105104
    106 6. Contact a MarketPowerPRO technical assistant to know your applicationID and set it to the applicationID field.
     1055. Check "Enable auto-prefix replication site name to URLs" option to enable replication of URLs in your website.
    107106
    108 7. Check "Enable auto-prefix replicationSiteName to URLs" option
     1076. Select a page (or empty) to redirect to in case a replicated site name is non-existing.
    109108
    110 8. Go to Settings > Permalinks then set your URL Structure to Post Name then click Save Changes
     1096. Go to Settings > Permalinks then set your URL Structure to Post Name then click Save Changes
  • marketpowerwp/tags/2.1.6/src/LePlugin/Core/AbstractController.php

    r1445352 r1957871  
    1818    protected $_plugin_dir;
    1919    protected $_plugin_dir_url;
     20    protected $_js_dir_url;
    2021    protected $_plugin_file;
    2122    private $_sql_dir;
     
    6566        $this->_config = $config;
    6667        $this->_plugin_dir_url = plugin_dir_url($this->_plugin_file);
     68        $this->_js_dir_url = $this->_plugin_dir_url . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR;
    6769
    6870        $this->_sql_dir = $this->_plugin_dir . self::SQL_FOLDER . DIRECTORY_SEPARATOR; //we add the slash!
     
    242244    }
    243245
    244     protected final function enqueue_script($name, $file_name, $deps = [])
     246    protected final function enqueue_script($name, $file_name, $deps = [], $version = false, $in_footer = false)
    245247    {
    246248        wp_enqueue_script($name,
    247             $this->_plugin_dir_url . DIRECTORY_SEPARATOR . "js/" . DIRECTORY_SEPARATOR . $file_name,
    248             $deps);
     249            $this->_js_dir_url . $file_name,
     250            $deps, $version, $in_footer);
    249251    }
    250252
  • marketpowerwp/tags/2.1.6/src/Multisoft/MPP/Replication/ReplicationController.php

    r1584743 r1957871  
    2727    const OPTION_CHECK_SITE_NAME_PATH = 'check_site_name_path';
    2828    const OPTION_CHECK_SITE_NAME_PATH_QUERY_FORMAT = 'check_site_name_path_query_format';
     29    const OPTION_DEFAULT_REPLICATED_SITE_NAME = 'default_replicated_site_name';
     30   
    2931    private $replicationGateway;
    3032    private $mpp_error_view;
     
    4345            $this->add_filter('option_siteurl', 'replication_site_url');
    4446        }
    45 
     47       
     48        if(file_exists(ABSPATH . "logs")){
     49            $logDir = ABSPATH . "logs";
     50        }else{
     51            $logDir = $this->_plugin_dir . '/logs';
     52        }
     53       
    4654        if (MPP_DEBUG) {
    47             $logger = new Logger($this->_plugin_dir . '/logs', LogLevel::DEBUG, array(
     55            $logger = new Logger($logDir, LogLevel::DEBUG, array(
    4856                'extension' => 'log',
    4957                'prefix' => 'mpp_replication_debug_'
    5058            ));
    5159        } else {
    52             $logger = new Logger($this->_plugin_dir . '/logs', LogLevel::INFO, array(
     60            $logger = new Logger($logDir, LogLevel::ERROR, array(
    5361                'extension' => 'log',
    5462                'prefix' => 'mpp_replication_'
     
    6573            [$this, 'index']
    6674        );
    67         if (!is_admin()) {
    68             ob_start();
    69             add_action('shutdown', function () {
    70                 $final = '';
    71                 $levels = ob_get_level();
    72 
    73                 for ($i = 0; $i < $levels; $i++) {
    74                     $final .= ob_get_clean();
    75                 }
    76                 echo apply_filters('final_output', $final);
    77             }, 0);
    78             $this->add_filter('final_output', 'mppe_autoprefix_content');
    79         }
     75       
     76        $this->add_action('wp_enqueue_scripts', 'mppe_enqueue_autoprefix', 99999);
     77       
     78        // Deprecated - Too Many Bugs
     79        // if (!is_admin()) {
     80        //     ob_start();
     81        //     add_action('shutdown', function () {
     82        //         $final = '';
     83        //         $levels = ob_get_level();
     84
     85        //         for ($i = 0; $i < $levels; $i++) {
     86        //             $final .= ob_get_clean();
     87        //         }
     88        //         echo apply_filters('final_output', $final);
     89        //     }, 0);
     90        //     $this->add_filter('final_output', 'mppe_autoprefix_content');
     91        // }
    8092
    8193    }
     
    113125            );
    114126        }
     127       
     128        $default_replicated_site_name = $this->_config->__get('default_replicated_site_name');
     129        if ($default_replicated_site_name) {
     130            $settingsGateway->update(
     131                self::OPTION_DEFAULT_REPLICATED_SITE_NAME,
     132                $default_replicated_site_name
     133            );
     134        }
    115135
    116136        $settingsGateway->update(self::OPTION_AUTOPREFIX, true);
     
    137157            self::OPTION_AUTOPREFIX
    138158        );
     159        $settingsGateway->registerSetting(
     160            $settingsGateway::GENERAL_TAB,
     161            self::SECTION_MPP_REPLICATION,
     162            self::OPTION_DEFAULT_REPLICATED_SITE_NAME
     163            );
    139164
    140165        $settingsGateway->addSettingsSection(
     
    194219        return $href['scheme'] . '://' . $_SERVER['HTTP_HOST'];
    195220    }
    196 
    197     public function mppe_autoprefix_content($output)
    198     {
    199         require_once $this->_plugin_dir . '/src/Multisoft/MPP/Replication/simple_html_dom.php';
    200         /* @var $replicationGateway ReplicationGateway */
    201         /* @var $settingsGateway SettingsGateway */
    202         $replicationGateway = $this->replicationGateway;
     221   
     222    public function mppe_enqueue_autoprefix(){
    203223        $settingsGateway = SettingsGateway::getInstance();
    204224        $autoprefix = $settingsGateway->get(self::OPTION_AUTOPREFIX);
    205 
    206         $xxx = $replicationGateway->get_replication_site_name();
    207         $host = Utils::get_domain(site_url());
    208         $web_address_host = Utils::get_domain($settingsGateway->get(CoreController::OPTION_WEB_ADDRESS));
    209         $html = str_get_html($output);
    210         if ($html) {
    211             foreach ($html->find('a') as $element) {
    212                 $href = parse_url($element->href);
    213                 $element_host = Utils::get_domain($href['host']);
    214                 if (strtolower($element_host) == strtolower($host) ||
    215                     strtolower($element_host) == strtolower($web_address_host)
    216                 ) {
    217                     $url_splice = explode('.', $href['host']);
    218                     $site_name = $url_splice[0];
    219                     if (strtolower($site_name) === 'www') {
    220                         $site_name = $url_splice[1];
    221                     }
    222                     if ($autoprefix && $site_name !== $xxx) {
    223                         $new_href = $href['scheme'] . '://' . $xxx . '.' .
    224                             Utils::str_replace_first($href['scheme'] . '://', '', $element->href);
    225                         $element->href = $new_href;
    226                     } else if (!$autoprefix && $site_name === $xxx) {
    227                         $new_href = Utils::str_replace_first($xxx . '.', '', $element->href);
    228                         $element->href = $new_href;
    229                     }
    230                 }
    231             }
    232         }
    233         return $html;
    234     }
     225       
     226        if($autoprefix){
     227            wp_enqueue_script('mppe-jurlp', $this->_js_dir_url . 'jurlp/jurlp.min.js', ['jquery']);
     228            wp_register_script('mppe-autoprefix', $this->_js_dir_url . 'mpp/autoprefix.js', ['jquery', 'mppe-jurlp'], '0', true);
     229           
     230            $replicationGateway = $this->replicationGateway;
     231            $xxx = $replicationGateway->get_replication_site_name(true);
     232            $host = $replicationGateway->get_original_site_url();
     233            $web_address_host = Utils::get_domain($settingsGateway->get(CoreController::OPTION_WEB_ADDRESS));
     234            wp_localize_script('mppe-autoprefix', 'MPPAUTOPREFIX', [
     235                    "replicated_site_name" => $xxx,
     236                    "mpp_base_url" => $web_address_host,
     237                    "site_url" => $host
     238                ]
     239            );
     240           
     241            wp_enqueue_script('mppe-autoprefix');
     242        }       
     243    }
     244   
     245    // @Deprecated - too many bugs
     246    // public function mppe_autoprefix_content($output)
     247    // {
     248    //     require_once $this->_plugin_dir . '/src/Multisoft/MPP/Replication/simple_html_dom.php';
     249    //     /* @var $replicationGateway ReplicationGateway */
     250    //     /* @var $settingsGateway SettingsGateway */
     251    //     $replicationGateway = $this->replicationGateway;
     252    //     $settingsGateway = SettingsGateway::getInstance();
     253    //     $autoprefix = $settingsGateway->get(self::OPTION_AUTOPREFIX);
     254
     255    //     $xxx = $replicationGateway->get_replication_site_name(true);
     256    //     if($xxx === false){
     257    //         return $output;
     258    //     }
     259    //     $host = Utils::get_domain(site_url());
     260    //     $web_address_host = Utils::get_domain($settingsGateway->get(CoreController::OPTION_WEB_ADDRESS));
     261    //     $html = str_get_html($output);
     262    //     if ($html) {
     263    //         foreach ($html->find('a') as $element) {
     264    //             $href = parse_url($element->href);
     265    //             $element_host = Utils::get_domain($href['host']);
     266    //             if (strtolower($element_host) == strtolower($host) ||
     267    //                 strtolower($element_host) == strtolower($web_address_host)
     268    //             ) {
     269    //                 $url_splice = explode('.', $href['host']);
     270    //                 $site_name = $url_splice[0];
     271    //                 if (strtolower($site_name) === 'www') {
     272    //                     $site_name = $url_splice[1];
     273    //                 }
     274    //                 if ($autoprefix && $site_name !== $xxx) {
     275    //                     $new_href = $href['scheme'] . '://' . $xxx . '.' .
     276    //                         Utils::str_replace_first($href['scheme'] . '://', '', $element->href);
     277    //                     $element->href = $new_href;
     278    //                 } else if (!$autoprefix && $site_name === $xxx) {
     279    //                     $new_href = Utils::str_replace_first($xxx . '.', '', $element->href);
     280    //                     $element->href = $new_href;
     281    //                 }
     282    //             }
     283    //         }
     284    //     }
     285    //     return $html;
     286    // }
    235287
    236288    public function mppe_replication_info($atts, $content = null)
     
    315367    public function mpp_replication_general_settings()
    316368    {
     369
    317370        /* @var $settingsGateway SettingsGateway */
    318371        $settingsGateway = SettingsGateway::getInstance();
     
    333386            self::OPTION_AUTOPREFIX, false
    334387        ));
     388        $replicationView->assign('replicated_site_name', $settingsGateway->get(
     389            self::OPTION_DEFAULT_REPLICATED_SITE_NAME
     390            ));
    335391        $replicationView->display();
    336392    }
  • marketpowerwp/tags/2.1.6/src/Multisoft/MPP/Replication/ReplicationGateway.php

    r1462934 r1957871  
    3737        return static::$instance;
    3838    }
    39 
    40     public function get_replication_site_name()
    41     {
     39   
     40    public function get_original_site_url(){
    4241        global $wpdb;
    4342
    4443        $prefix = $wpdb->prefix;
    45 
     44       
    4645        $original_site_url = $wpdb->get_var("SELECT option_value FROM {$prefix}options WHERE option_name = 'siteurl'");
    4746
     
    4948
    5049        $original_site_url = Utils::str_replace_first('www.', '', strtolower($original_site_url));
     50   
     51        return $original_site_url;
     52    }
     53
     54    public function get_replication_site_name($false_empty = false)
     55    {
     56        $settingsGateway = SettingsGateway::getInstance();
     57       
     58        global $wpdb;
     59
     60        $prefix = $wpdb->prefix;
     61
     62        $original_site_url = $this->get_original_site_url();
    5163
    5264        $server_name = Utils::str_replace_first('www.', '', strtolower($_SERVER["HTTP_HOST"]));
     
    5567
    5668        if (!strlen($xxx) || $xxx === 'localhost' || $xxx === 'www') {
    57 
    58             $xxx = "admin";
     69            if($false_empty){
     70                return false;
     71            }
     72            $xxx = $settingsGateway->get(ReplicationController::OPTION_DEFAULT_REPLICATED_SITE_NAME);
    5973
    6074        }
  • marketpowerwp/tags/2.1.6/views/mpp/replication/general_settings_section.php

    r1445361 r1957871  
    11<table class="form-table">
    22    <tbody>
     3    <tr valign="top">
     4        <th width="35%" align="left">
     5            <label for="default_replicated_site_name">Default replicated site name</label>
     6        </th>
     7        <td align="left">
     8            <input type="text" name="default_replicated_site_name" value="<?php echo $this->replicated_site_name; ?>"/>
     9            <p class="description">Default replicated site name to use if not specified.</p>
     10        </td>
     11    </tr>
    312    <tr valign="top">
    413        <th width="35%" align="left">
  • marketpowerwp/trunk/config/replication_settings.json

    r1445352 r1957871  
    1515    "key": "default_multisoft_mpp_check_site_name_query_format",
    1616    "value": "hashKey=%s&siteName=%s"
     17  },
     18  {
     19    "key": "default_replicated_site_name",
     20    "value": "admin"
    1721  }
    1822]
  • marketpowerwp/trunk/leplugin.php

    r1584743 r1957871  
    33/**
    44 * Plugin Name: Multisoft MarketPowerPRO Tools
    5  * Description: Integration of Market Power Pro to wordpress
    6  * Version: 2.1.4
    7  * Author: Rodine Mark Paul L. Villar, Dexter John Campos
    8  * Author URI: mailto:dean.villar@gmail.com?subject= Multisoft MPP Tools
     5 * Description: Integration of MarketPowerPro to Wordpress
     6 * Version: 2.1.6
     7 * Author: Rodine Mark Paul L. Villar
     8 * Author URI: mailto:dine@multisoft.com?subject=Multisoft+MarketPowerPRO+Tools
    99 */
    1010define('MPP_DEBUG', false || WP_DEBUG);
     
    1313    require ABSPATH . 'wp-admin/includes/plugin.php';
    1414}
     15
     16require 'plugin-update-checker/plugin-update-checker.php';
     17Puc_v4_Factory::buildUpdateChecker(
     18    'https://s3.amazonaws.com/multisoft-wordpress/plugins/marketpowerwp/release.json',
     19    __FILE__,
     20    'marketpowerwp'
     21);
     22
    1523include_once 'autoloader.php';
    1624
     
    6573);
    6674
    67 if (is_admin()) {
     75/*if (is_admin()) {
    6876    $multisoft_config_file = $multisoft_dirname . '/config/distributor_settings.json';
    6977    $multisoft_config = null;
     
    102110    $multisoft_pluginname,
    103111    $multisoft_config
    104 );
     112);*/
    105113unset(
    106114    $multisoft_dirname,
  • marketpowerwp/trunk/readme.txt

    r1584743 r1957871  
    1 === MarketPowerWP ===
    2 Contributors: dean.villar@gmail.com
     1=== MarketPowerWP ===
     2Contributors: dine@multisoft.com
    33Tags: marketpowerpro, multisoft
    44Requires at least: 3.4+
    5 Stable tag: 2.1.4
     5Stable tag: 2.1.6
    66License: Commercial
    77
     
    8686</div>
    8787
    88  
    8988
    9089 [1]: http://www.marketpowerpro.com "f"
     
    9493[youtube https://www.youtube.com/watch?v=BkHmPWjUt4M]
    9594
    96 1. Add the plugin to your wordpress site.
     951. Install and activate the plugin to your wordpress site.
    9796
    98 2. Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
     972. Go to the MarketPowerPRO > Settings menu in your wordpress admin.
    9998
    100 3. Login to your administrator page yourwordpressblog.com/wp-admin.
     993. Set your Base MarketPowerPRO Web address, where your MarketPowerPRO system is located.
    101100
    102 4. Go to MarketPowerPRO.
     1014. Contact a MarketPowerPRO technical assistant to know your applicationID and set it to the applicationID field.
    103102
    104 5. Set your Base MPPE Web address, where your MarketPowerPRO system is located.
     1035. Set (or empty) a default replicated site name to be used in case none was provided in the URL (the default is "admin")
    105104
    106 6. Contact a MarketPowerPRO technical assistant to know your applicationID and set it to the applicationID field.
     1055. Check "Enable auto-prefix replication site name to URLs" option to enable replication of URLs in your website.
    107106
    108 7. Check "Enable auto-prefix replicationSiteName to URLs" option
     1076. Select a page (or empty) to redirect to in case a replicated site name is non-existing.
    109108
    110 8. Go to Settings > Permalinks then set your URL Structure to Post Name then click Save Changes
     1096. Go to Settings > Permalinks then set your URL Structure to Post Name then click Save Changes
  • marketpowerwp/trunk/src/LePlugin/Core/AbstractController.php

    r1445352 r1957871  
    1818    protected $_plugin_dir;
    1919    protected $_plugin_dir_url;
     20    protected $_js_dir_url;
    2021    protected $_plugin_file;
    2122    private $_sql_dir;
     
    6566        $this->_config = $config;
    6667        $this->_plugin_dir_url = plugin_dir_url($this->_plugin_file);
     68        $this->_js_dir_url = $this->_plugin_dir_url . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR;
    6769
    6870        $this->_sql_dir = $this->_plugin_dir . self::SQL_FOLDER . DIRECTORY_SEPARATOR; //we add the slash!
     
    242244    }
    243245
    244     protected final function enqueue_script($name, $file_name, $deps = [])
     246    protected final function enqueue_script($name, $file_name, $deps = [], $version = false, $in_footer = false)
    245247    {
    246248        wp_enqueue_script($name,
    247             $this->_plugin_dir_url . DIRECTORY_SEPARATOR . "js/" . DIRECTORY_SEPARATOR . $file_name,
    248             $deps);
     249            $this->_js_dir_url . $file_name,
     250            $deps, $version, $in_footer);
    249251    }
    250252
  • marketpowerwp/trunk/src/Multisoft/MPP/Replication/ReplicationController.php

    r1584743 r1957871  
    2727    const OPTION_CHECK_SITE_NAME_PATH = 'check_site_name_path';
    2828    const OPTION_CHECK_SITE_NAME_PATH_QUERY_FORMAT = 'check_site_name_path_query_format';
     29    const OPTION_DEFAULT_REPLICATED_SITE_NAME = 'default_replicated_site_name';
     30   
    2931    private $replicationGateway;
    3032    private $mpp_error_view;
     
    4345            $this->add_filter('option_siteurl', 'replication_site_url');
    4446        }
    45 
     47       
     48        if(file_exists(ABSPATH . "logs")){
     49            $logDir = ABSPATH . "logs";
     50        }else{
     51            $logDir = $this->_plugin_dir . '/logs';
     52        }
     53       
    4654        if (MPP_DEBUG) {
    47             $logger = new Logger($this->_plugin_dir . '/logs', LogLevel::DEBUG, array(
     55            $logger = new Logger($logDir, LogLevel::DEBUG, array(
    4856                'extension' => 'log',
    4957                'prefix' => 'mpp_replication_debug_'
    5058            ));
    5159        } else {
    52             $logger = new Logger($this->_plugin_dir . '/logs', LogLevel::INFO, array(
     60            $logger = new Logger($logDir, LogLevel::ERROR, array(
    5361                'extension' => 'log',
    5462                'prefix' => 'mpp_replication_'
     
    6573            [$this, 'index']
    6674        );
    67         if (!is_admin()) {
    68             ob_start();
    69             add_action('shutdown', function () {
    70                 $final = '';
    71                 $levels = ob_get_level();
    72 
    73                 for ($i = 0; $i < $levels; $i++) {
    74                     $final .= ob_get_clean();
    75                 }
    76                 echo apply_filters('final_output', $final);
    77             }, 0);
    78             $this->add_filter('final_output', 'mppe_autoprefix_content');
    79         }
     75       
     76        $this->add_action('wp_enqueue_scripts', 'mppe_enqueue_autoprefix', 99999);
     77       
     78        // Deprecated - Too Many Bugs
     79        // if (!is_admin()) {
     80        //     ob_start();
     81        //     add_action('shutdown', function () {
     82        //         $final = '';
     83        //         $levels = ob_get_level();
     84
     85        //         for ($i = 0; $i < $levels; $i++) {
     86        //             $final .= ob_get_clean();
     87        //         }
     88        //         echo apply_filters('final_output', $final);
     89        //     }, 0);
     90        //     $this->add_filter('final_output', 'mppe_autoprefix_content');
     91        // }
    8092
    8193    }
     
    113125            );
    114126        }
     127       
     128        $default_replicated_site_name = $this->_config->__get('default_replicated_site_name');
     129        if ($default_replicated_site_name) {
     130            $settingsGateway->update(
     131                self::OPTION_DEFAULT_REPLICATED_SITE_NAME,
     132                $default_replicated_site_name
     133            );
     134        }
    115135
    116136        $settingsGateway->update(self::OPTION_AUTOPREFIX, true);
     
    137157            self::OPTION_AUTOPREFIX
    138158        );
     159        $settingsGateway->registerSetting(
     160            $settingsGateway::GENERAL_TAB,
     161            self::SECTION_MPP_REPLICATION,
     162            self::OPTION_DEFAULT_REPLICATED_SITE_NAME
     163            );
    139164
    140165        $settingsGateway->addSettingsSection(
     
    194219        return $href['scheme'] . '://' . $_SERVER['HTTP_HOST'];
    195220    }
    196 
    197     public function mppe_autoprefix_content($output)
    198     {
    199         require_once $this->_plugin_dir . '/src/Multisoft/MPP/Replication/simple_html_dom.php';
    200         /* @var $replicationGateway ReplicationGateway */
    201         /* @var $settingsGateway SettingsGateway */
    202         $replicationGateway = $this->replicationGateway;
     221   
     222    public function mppe_enqueue_autoprefix(){
    203223        $settingsGateway = SettingsGateway::getInstance();
    204224        $autoprefix = $settingsGateway->get(self::OPTION_AUTOPREFIX);
    205 
    206         $xxx = $replicationGateway->get_replication_site_name();
    207         $host = Utils::get_domain(site_url());
    208         $web_address_host = Utils::get_domain($settingsGateway->get(CoreController::OPTION_WEB_ADDRESS));
    209         $html = str_get_html($output);
    210         if ($html) {
    211             foreach ($html->find('a') as $element) {
    212                 $href = parse_url($element->href);
    213                 $element_host = Utils::get_domain($href['host']);
    214                 if (strtolower($element_host) == strtolower($host) ||
    215                     strtolower($element_host) == strtolower($web_address_host)
    216                 ) {
    217                     $url_splice = explode('.', $href['host']);
    218                     $site_name = $url_splice[0];
    219                     if (strtolower($site_name) === 'www') {
    220                         $site_name = $url_splice[1];
    221                     }
    222                     if ($autoprefix && $site_name !== $xxx) {
    223                         $new_href = $href['scheme'] . '://' . $xxx . '.' .
    224                             Utils::str_replace_first($href['scheme'] . '://', '', $element->href);
    225                         $element->href = $new_href;
    226                     } else if (!$autoprefix && $site_name === $xxx) {
    227                         $new_href = Utils::str_replace_first($xxx . '.', '', $element->href);
    228                         $element->href = $new_href;
    229                     }
    230                 }
    231             }
    232         }
    233         return $html;
    234     }
     225       
     226        if($autoprefix){
     227            wp_enqueue_script('mppe-jurlp', $this->_js_dir_url . 'jurlp/jurlp.min.js', ['jquery']);
     228            wp_register_script('mppe-autoprefix', $this->_js_dir_url . 'mpp/autoprefix.js', ['jquery', 'mppe-jurlp'], '0', true);
     229           
     230            $replicationGateway = $this->replicationGateway;
     231            $xxx = $replicationGateway->get_replication_site_name(true);
     232            $host = $replicationGateway->get_original_site_url();
     233            $web_address_host = Utils::get_domain($settingsGateway->get(CoreController::OPTION_WEB_ADDRESS));
     234            wp_localize_script('mppe-autoprefix', 'MPPAUTOPREFIX', [
     235                    "replicated_site_name" => $xxx,
     236                    "mpp_base_url" => $web_address_host,
     237                    "site_url" => $host
     238                ]
     239            );
     240           
     241            wp_enqueue_script('mppe-autoprefix');
     242        }       
     243    }
     244   
     245    // @Deprecated - too many bugs
     246    // public function mppe_autoprefix_content($output)
     247    // {
     248    //     require_once $this->_plugin_dir . '/src/Multisoft/MPP/Replication/simple_html_dom.php';
     249    //     /* @var $replicationGateway ReplicationGateway */
     250    //     /* @var $settingsGateway SettingsGateway */
     251    //     $replicationGateway = $this->replicationGateway;
     252    //     $settingsGateway = SettingsGateway::getInstance();
     253    //     $autoprefix = $settingsGateway->get(self::OPTION_AUTOPREFIX);
     254
     255    //     $xxx = $replicationGateway->get_replication_site_name(true);
     256    //     if($xxx === false){
     257    //         return $output;
     258    //     }
     259    //     $host = Utils::get_domain(site_url());
     260    //     $web_address_host = Utils::get_domain($settingsGateway->get(CoreController::OPTION_WEB_ADDRESS));
     261    //     $html = str_get_html($output);
     262    //     if ($html) {
     263    //         foreach ($html->find('a') as $element) {
     264    //             $href = parse_url($element->href);
     265    //             $element_host = Utils::get_domain($href['host']);
     266    //             if (strtolower($element_host) == strtolower($host) ||
     267    //                 strtolower($element_host) == strtolower($web_address_host)
     268    //             ) {
     269    //                 $url_splice = explode('.', $href['host']);
     270    //                 $site_name = $url_splice[0];
     271    //                 if (strtolower($site_name) === 'www') {
     272    //                     $site_name = $url_splice[1];
     273    //                 }
     274    //                 if ($autoprefix && $site_name !== $xxx) {
     275    //                     $new_href = $href['scheme'] . '://' . $xxx . '.' .
     276    //                         Utils::str_replace_first($href['scheme'] . '://', '', $element->href);
     277    //                     $element->href = $new_href;
     278    //                 } else if (!$autoprefix && $site_name === $xxx) {
     279    //                     $new_href = Utils::str_replace_first($xxx . '.', '', $element->href);
     280    //                     $element->href = $new_href;
     281    //                 }
     282    //             }
     283    //         }
     284    //     }
     285    //     return $html;
     286    // }
    235287
    236288    public function mppe_replication_info($atts, $content = null)
     
    315367    public function mpp_replication_general_settings()
    316368    {
     369
    317370        /* @var $settingsGateway SettingsGateway */
    318371        $settingsGateway = SettingsGateway::getInstance();
     
    333386            self::OPTION_AUTOPREFIX, false
    334387        ));
     388        $replicationView->assign('replicated_site_name', $settingsGateway->get(
     389            self::OPTION_DEFAULT_REPLICATED_SITE_NAME
     390            ));
    335391        $replicationView->display();
    336392    }
  • marketpowerwp/trunk/src/Multisoft/MPP/Replication/ReplicationGateway.php

    r1462934 r1957871  
    3737        return static::$instance;
    3838    }
    39 
    40     public function get_replication_site_name()
    41     {
     39   
     40    public function get_original_site_url(){
    4241        global $wpdb;
    4342
    4443        $prefix = $wpdb->prefix;
    45 
     44       
    4645        $original_site_url = $wpdb->get_var("SELECT option_value FROM {$prefix}options WHERE option_name = 'siteurl'");
    4746
     
    4948
    5049        $original_site_url = Utils::str_replace_first('www.', '', strtolower($original_site_url));
     50   
     51        return $original_site_url;
     52    }
     53
     54    public function get_replication_site_name($false_empty = false)
     55    {
     56        $settingsGateway = SettingsGateway::getInstance();
     57       
     58        global $wpdb;
     59
     60        $prefix = $wpdb->prefix;
     61
     62        $original_site_url = $this->get_original_site_url();
    5163
    5264        $server_name = Utils::str_replace_first('www.', '', strtolower($_SERVER["HTTP_HOST"]));
     
    5567
    5668        if (!strlen($xxx) || $xxx === 'localhost' || $xxx === 'www') {
    57 
    58             $xxx = "admin";
     69            if($false_empty){
     70                return false;
     71            }
     72            $xxx = $settingsGateway->get(ReplicationController::OPTION_DEFAULT_REPLICATED_SITE_NAME);
    5973
    6074        }
  • marketpowerwp/trunk/views/mpp/replication/general_settings_section.php

    r1445361 r1957871  
    11<table class="form-table">
    22    <tbody>
     3    <tr valign="top">
     4        <th width="35%" align="left">
     5            <label for="default_replicated_site_name">Default replicated site name</label>
     6        </th>
     7        <td align="left">
     8            <input type="text" name="default_replicated_site_name" value="<?php echo $this->replicated_site_name; ?>"/>
     9            <p class="description">Default replicated site name to use if not specified.</p>
     10        </td>
     11    </tr>
    312    <tr valign="top">
    413        <th width="35%" align="left">
Note: See TracChangeset for help on using the changeset viewer.