Changeset 1957871
- Timestamp:
- 10/17/2018 06:57:15 AM (7 years ago)
- Location:
- marketpowerwp
- Files:
-
- 14 edited
- 1 copied
-
tags/2.1.6 (copied) (copied from marketpowerwp/trunk)
-
tags/2.1.6/config/replication_settings.json (modified) (1 diff)
-
tags/2.1.6/leplugin.php (modified) (4 diffs)
-
tags/2.1.6/readme.txt (modified) (3 diffs)
-
tags/2.1.6/src/LePlugin/Core/AbstractController.php (modified) (3 diffs)
-
tags/2.1.6/src/Multisoft/MPP/Replication/ReplicationController.php (modified) (8 diffs)
-
tags/2.1.6/src/Multisoft/MPP/Replication/ReplicationGateway.php (modified) (3 diffs)
-
tags/2.1.6/views/mpp/replication/general_settings_section.php (modified) (1 diff)
-
trunk/config/replication_settings.json (modified) (1 diff)
-
trunk/leplugin.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/LePlugin/Core/AbstractController.php (modified) (3 diffs)
-
trunk/src/Multisoft/MPP/Replication/ReplicationController.php (modified) (8 diffs)
-
trunk/src/Multisoft/MPP/Replication/ReplicationGateway.php (modified) (3 diffs)
-
trunk/views/mpp/replication/general_settings_section.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
marketpowerwp/tags/2.1.6/config/replication_settings.json
r1445352 r1957871 15 15 "key": "default_multisoft_mpp_check_site_name_query_format", 16 16 "value": "hashKey=%s&siteName=%s" 17 }, 18 { 19 "key": "default_replicated_site_name", 20 "value": "admin" 17 21 } 18 22 ] -
marketpowerwp/tags/2.1.6/leplugin.php
r1584743 r1957871 3 3 /** 4 4 * Plugin Name: Multisoft MarketPowerPRO Tools 5 * Description: Integration of Market Power Pro to wordpress6 * Version: 2.1. 47 * Author: Rodine Mark Paul L. Villar , Dexter John Campos8 * Author URI: mailto:d ean.villar@gmail.com?subject= Multisoft MPPTools5 * 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 9 9 */ 10 10 define('MPP_DEBUG', false || WP_DEBUG); … … 13 13 require ABSPATH . 'wp-admin/includes/plugin.php'; 14 14 } 15 16 require 'plugin-update-checker/plugin-update-checker.php'; 17 Puc_v4_Factory::buildUpdateChecker( 18 'https://s3.amazonaws.com/multisoft-wordpress/plugins/marketpowerwp/release.json', 19 __FILE__, 20 'marketpowerwp' 21 ); 22 15 23 include_once 'autoloader.php'; 16 24 … … 65 73 ); 66 74 67 if (is_admin()) {75 /*if (is_admin()) { 68 76 $multisoft_config_file = $multisoft_dirname . '/config/distributor_settings.json'; 69 77 $multisoft_config = null; … … 102 110 $multisoft_pluginname, 103 111 $multisoft_config 104 ); 112 );*/ 105 113 unset( 106 114 $multisoft_dirname, -
marketpowerwp/tags/2.1.6/readme.txt
r1584743 r1957871 1 === MarketPowerWP ===2 Contributors: d ean.villar@gmail.com1 === MarketPowerWP === 2 Contributors: dine@multisoft.com 3 3 Tags: marketpowerpro, multisoft 4 4 Requires at least: 3.4+ 5 Stable tag: 2.1. 45 Stable tag: 2.1.6 6 6 License: Commercial 7 7 … … 86 86 </div> 87 87 88 89 88 90 89 [1]: http://www.marketpowerpro.com "f" … … 94 93 [youtube https://www.youtube.com/watch?v=BkHmPWjUt4M] 95 94 96 1. Addthe plugin to your wordpress site.95 1. Install and activate the plugin to your wordpress site. 97 96 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.97 2. Go to the MarketPowerPRO > Settings menu in your wordpress admin. 99 98 100 3. Login to your administrator page yourwordpressblog.com/wp-admin.99 3. Set your Base MarketPowerPRO Web address, where your MarketPowerPRO system is located. 101 100 102 4. Go to MarketPowerPRO.101 4. Contact a MarketPowerPRO technical assistant to know your applicationID and set it to the applicationID field. 103 102 104 5. Set your Base MPPE Web address, where your MarketPowerPRO system is located.103 5. Set (or empty) a default replicated site name to be used in case none was provided in the URL (the default is "admin") 105 104 106 6. Contact a MarketPowerPRO technical assistant to know your applicationID and set it to the applicationID field.105 5. Check "Enable auto-prefix replication site name to URLs" option to enable replication of URLs in your website. 107 106 108 7. Check "Enable auto-prefix replicationSiteName to URLs" option 107 6. Select a page (or empty) to redirect to in case a replicated site name is non-existing. 109 108 110 8. Go to Settings > Permalinks then set your URL Structure to Post Name then click Save Changes109 6. 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 18 18 protected $_plugin_dir; 19 19 protected $_plugin_dir_url; 20 protected $_js_dir_url; 20 21 protected $_plugin_file; 21 22 private $_sql_dir; … … 65 66 $this->_config = $config; 66 67 $this->_plugin_dir_url = plugin_dir_url($this->_plugin_file); 68 $this->_js_dir_url = $this->_plugin_dir_url . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR; 67 69 68 70 $this->_sql_dir = $this->_plugin_dir . self::SQL_FOLDER . DIRECTORY_SEPARATOR; //we add the slash! … … 242 244 } 243 245 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) 245 247 { 246 248 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); 249 251 } 250 252 -
marketpowerwp/tags/2.1.6/src/Multisoft/MPP/Replication/ReplicationController.php
r1584743 r1957871 27 27 const OPTION_CHECK_SITE_NAME_PATH = 'check_site_name_path'; 28 28 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 29 31 private $replicationGateway; 30 32 private $mpp_error_view; … … 43 45 $this->add_filter('option_siteurl', 'replication_site_url'); 44 46 } 45 47 48 if(file_exists(ABSPATH . "logs")){ 49 $logDir = ABSPATH . "logs"; 50 }else{ 51 $logDir = $this->_plugin_dir . '/logs'; 52 } 53 46 54 if (MPP_DEBUG) { 47 $logger = new Logger($ this->_plugin_dir . '/logs', LogLevel::DEBUG, array(55 $logger = new Logger($logDir, LogLevel::DEBUG, array( 48 56 'extension' => 'log', 49 57 'prefix' => 'mpp_replication_debug_' 50 58 )); 51 59 } else { 52 $logger = new Logger($ this->_plugin_dir . '/logs', LogLevel::INFO, array(60 $logger = new Logger($logDir, LogLevel::ERROR, array( 53 61 'extension' => 'log', 54 62 'prefix' => 'mpp_replication_' … … 65 73 [$this, 'index'] 66 74 ); 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 // } 80 92 81 93 } … … 113 125 ); 114 126 } 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 } 115 135 116 136 $settingsGateway->update(self::OPTION_AUTOPREFIX, true); … … 137 157 self::OPTION_AUTOPREFIX 138 158 ); 159 $settingsGateway->registerSetting( 160 $settingsGateway::GENERAL_TAB, 161 self::SECTION_MPP_REPLICATION, 162 self::OPTION_DEFAULT_REPLICATED_SITE_NAME 163 ); 139 164 140 165 $settingsGateway->addSettingsSection( … … 194 219 return $href['scheme'] . '://' . $_SERVER['HTTP_HOST']; 195 220 } 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(){ 203 223 $settingsGateway = SettingsGateway::getInstance(); 204 224 $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 // } 235 287 236 288 public function mppe_replication_info($atts, $content = null) … … 315 367 public function mpp_replication_general_settings() 316 368 { 369 317 370 /* @var $settingsGateway SettingsGateway */ 318 371 $settingsGateway = SettingsGateway::getInstance(); … … 333 386 self::OPTION_AUTOPREFIX, false 334 387 )); 388 $replicationView->assign('replicated_site_name', $settingsGateway->get( 389 self::OPTION_DEFAULT_REPLICATED_SITE_NAME 390 )); 335 391 $replicationView->display(); 336 392 } -
marketpowerwp/tags/2.1.6/src/Multisoft/MPP/Replication/ReplicationGateway.php
r1462934 r1957871 37 37 return static::$instance; 38 38 } 39 40 public function get_replication_site_name() 41 { 39 40 public function get_original_site_url(){ 42 41 global $wpdb; 43 42 44 43 $prefix = $wpdb->prefix; 45 44 46 45 $original_site_url = $wpdb->get_var("SELECT option_value FROM {$prefix}options WHERE option_name = 'siteurl'"); 47 46 … … 49 48 50 49 $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(); 51 63 52 64 $server_name = Utils::str_replace_first('www.', '', strtolower($_SERVER["HTTP_HOST"])); … … 55 67 56 68 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); 59 73 60 74 } -
marketpowerwp/tags/2.1.6/views/mpp/replication/general_settings_section.php
r1445361 r1957871 1 1 <table class="form-table"> 2 2 <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> 3 12 <tr valign="top"> 4 13 <th width="35%" align="left"> -
marketpowerwp/trunk/config/replication_settings.json
r1445352 r1957871 15 15 "key": "default_multisoft_mpp_check_site_name_query_format", 16 16 "value": "hashKey=%s&siteName=%s" 17 }, 18 { 19 "key": "default_replicated_site_name", 20 "value": "admin" 17 21 } 18 22 ] -
marketpowerwp/trunk/leplugin.php
r1584743 r1957871 3 3 /** 4 4 * Plugin Name: Multisoft MarketPowerPRO Tools 5 * Description: Integration of Market Power Pro to wordpress6 * Version: 2.1. 47 * Author: Rodine Mark Paul L. Villar , Dexter John Campos8 * Author URI: mailto:d ean.villar@gmail.com?subject= Multisoft MPPTools5 * 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 9 9 */ 10 10 define('MPP_DEBUG', false || WP_DEBUG); … … 13 13 require ABSPATH . 'wp-admin/includes/plugin.php'; 14 14 } 15 16 require 'plugin-update-checker/plugin-update-checker.php'; 17 Puc_v4_Factory::buildUpdateChecker( 18 'https://s3.amazonaws.com/multisoft-wordpress/plugins/marketpowerwp/release.json', 19 __FILE__, 20 'marketpowerwp' 21 ); 22 15 23 include_once 'autoloader.php'; 16 24 … … 65 73 ); 66 74 67 if (is_admin()) {75 /*if (is_admin()) { 68 76 $multisoft_config_file = $multisoft_dirname . '/config/distributor_settings.json'; 69 77 $multisoft_config = null; … … 102 110 $multisoft_pluginname, 103 111 $multisoft_config 104 ); 112 );*/ 105 113 unset( 106 114 $multisoft_dirname, -
marketpowerwp/trunk/readme.txt
r1584743 r1957871 1 === MarketPowerWP ===2 Contributors: d ean.villar@gmail.com1 === MarketPowerWP === 2 Contributors: dine@multisoft.com 3 3 Tags: marketpowerpro, multisoft 4 4 Requires at least: 3.4+ 5 Stable tag: 2.1. 45 Stable tag: 2.1.6 6 6 License: Commercial 7 7 … … 86 86 </div> 87 87 88 89 88 90 89 [1]: http://www.marketpowerpro.com "f" … … 94 93 [youtube https://www.youtube.com/watch?v=BkHmPWjUt4M] 95 94 96 1. Addthe plugin to your wordpress site.95 1. Install and activate the plugin to your wordpress site. 97 96 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.97 2. Go to the MarketPowerPRO > Settings menu in your wordpress admin. 99 98 100 3. Login to your administrator page yourwordpressblog.com/wp-admin.99 3. Set your Base MarketPowerPRO Web address, where your MarketPowerPRO system is located. 101 100 102 4. Go to MarketPowerPRO.101 4. Contact a MarketPowerPRO technical assistant to know your applicationID and set it to the applicationID field. 103 102 104 5. Set your Base MPPE Web address, where your MarketPowerPRO system is located.103 5. Set (or empty) a default replicated site name to be used in case none was provided in the URL (the default is "admin") 105 104 106 6. Contact a MarketPowerPRO technical assistant to know your applicationID and set it to the applicationID field.105 5. Check "Enable auto-prefix replication site name to URLs" option to enable replication of URLs in your website. 107 106 108 7. Check "Enable auto-prefix replicationSiteName to URLs" option 107 6. Select a page (or empty) to redirect to in case a replicated site name is non-existing. 109 108 110 8. Go to Settings > Permalinks then set your URL Structure to Post Name then click Save Changes109 6. 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 18 18 protected $_plugin_dir; 19 19 protected $_plugin_dir_url; 20 protected $_js_dir_url; 20 21 protected $_plugin_file; 21 22 private $_sql_dir; … … 65 66 $this->_config = $config; 66 67 $this->_plugin_dir_url = plugin_dir_url($this->_plugin_file); 68 $this->_js_dir_url = $this->_plugin_dir_url . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR; 67 69 68 70 $this->_sql_dir = $this->_plugin_dir . self::SQL_FOLDER . DIRECTORY_SEPARATOR; //we add the slash! … … 242 244 } 243 245 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) 245 247 { 246 248 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); 249 251 } 250 252 -
marketpowerwp/trunk/src/Multisoft/MPP/Replication/ReplicationController.php
r1584743 r1957871 27 27 const OPTION_CHECK_SITE_NAME_PATH = 'check_site_name_path'; 28 28 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 29 31 private $replicationGateway; 30 32 private $mpp_error_view; … … 43 45 $this->add_filter('option_siteurl', 'replication_site_url'); 44 46 } 45 47 48 if(file_exists(ABSPATH . "logs")){ 49 $logDir = ABSPATH . "logs"; 50 }else{ 51 $logDir = $this->_plugin_dir . '/logs'; 52 } 53 46 54 if (MPP_DEBUG) { 47 $logger = new Logger($ this->_plugin_dir . '/logs', LogLevel::DEBUG, array(55 $logger = new Logger($logDir, LogLevel::DEBUG, array( 48 56 'extension' => 'log', 49 57 'prefix' => 'mpp_replication_debug_' 50 58 )); 51 59 } else { 52 $logger = new Logger($ this->_plugin_dir . '/logs', LogLevel::INFO, array(60 $logger = new Logger($logDir, LogLevel::ERROR, array( 53 61 'extension' => 'log', 54 62 'prefix' => 'mpp_replication_' … … 65 73 [$this, 'index'] 66 74 ); 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 // } 80 92 81 93 } … … 113 125 ); 114 126 } 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 } 115 135 116 136 $settingsGateway->update(self::OPTION_AUTOPREFIX, true); … … 137 157 self::OPTION_AUTOPREFIX 138 158 ); 159 $settingsGateway->registerSetting( 160 $settingsGateway::GENERAL_TAB, 161 self::SECTION_MPP_REPLICATION, 162 self::OPTION_DEFAULT_REPLICATED_SITE_NAME 163 ); 139 164 140 165 $settingsGateway->addSettingsSection( … … 194 219 return $href['scheme'] . '://' . $_SERVER['HTTP_HOST']; 195 220 } 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(){ 203 223 $settingsGateway = SettingsGateway::getInstance(); 204 224 $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 // } 235 287 236 288 public function mppe_replication_info($atts, $content = null) … … 315 367 public function mpp_replication_general_settings() 316 368 { 369 317 370 /* @var $settingsGateway SettingsGateway */ 318 371 $settingsGateway = SettingsGateway::getInstance(); … … 333 386 self::OPTION_AUTOPREFIX, false 334 387 )); 388 $replicationView->assign('replicated_site_name', $settingsGateway->get( 389 self::OPTION_DEFAULT_REPLICATED_SITE_NAME 390 )); 335 391 $replicationView->display(); 336 392 } -
marketpowerwp/trunk/src/Multisoft/MPP/Replication/ReplicationGateway.php
r1462934 r1957871 37 37 return static::$instance; 38 38 } 39 40 public function get_replication_site_name() 41 { 39 40 public function get_original_site_url(){ 42 41 global $wpdb; 43 42 44 43 $prefix = $wpdb->prefix; 45 44 46 45 $original_site_url = $wpdb->get_var("SELECT option_value FROM {$prefix}options WHERE option_name = 'siteurl'"); 47 46 … … 49 48 50 49 $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(); 51 63 52 64 $server_name = Utils::str_replace_first('www.', '', strtolower($_SERVER["HTTP_HOST"])); … … 55 67 56 68 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); 59 73 60 74 } -
marketpowerwp/trunk/views/mpp/replication/general_settings_section.php
r1445361 r1957871 1 1 <table class="form-table"> 2 2 <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> 3 12 <tr valign="top"> 4 13 <th width="35%" align="left">
Note: See TracChangeset
for help on using the changeset viewer.