Changeset 2108980
- Timestamp:
- 06/19/2019 02:28:12 PM (7 years ago)
- Location:
- autooffice/trunk
- Files:
-
- 10 edited
-
assets/css/core.css (modified) (1 diff)
-
autooffice_plugin.php (modified) (2 diffs)
-
includes/AutoofficeModel.php (modified) (6 diffs)
-
includes/AutoofficeOptions.php (modified) (7 diffs)
-
includes/AutoofficeWork.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
views/plugin_settings_page.php (modified) (3 diffs)
-
views/plugin_settings_page_css.php (modified) (1 diff)
-
views/plugin_settings_page_html.php (modified) (1 diff)
-
views/plugin_settings_page_js.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
autooffice/trunk/assets/css/core.css
r2019049 r2108980 1 #autooffice input[type=submit] { 2 margin: 4px 0 0 0; 3 } -
autooffice/trunk/autooffice_plugin.php
r2105526 r2108980 5 5 Description: Плагин для интеграции рассылки с сервисом АвтоОфис. Позволяет встроить форму подписки на любую из рассылок АвтоОфис через shortcode или html-код. Поддерживает каналы рекламы. Для работы плагина требуется создать тематическую рассылку в магазине на сервисе АвтоОфис 6 6 Author: Autooffice 7 Version: 1.0.0 17 Version: 1.0.02 8 8 Author URI: https://profiles.wordpress.org/autooffice#content-plugins 9 9 */ 10 11 if (!session_id()) { 12 session_start(); 13 } 10 14 11 15 define('AOPF_AUTOOFFICE_DIR', plugin_dir_path(__FILE__)); … … 22 26 23 27 function aopf_autooffice_load() { 24 25 $is_admin_page = false; 26 27 if (!empty($_GET['page']) && preg_match('/autooffice/i', $_GET['page'])) { 28 $is_admin_page = true; 29 } 30 28 31 29 if (is_admin()) { 32 33 if (!empty($is_admin_page)) {34 35 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/bootstrap.min.css', __FILE__));36 37 if (empty(AOPF_DEBUG)) {38 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/admin.css', __FILE__));39 } else {40 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/admin.min.css', __FILE__));41 }42 30 43 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/bootstrap.min.js', __FILE__)); 44 45 if (!empty(AOPF_DEBUG)) { 46 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/admin.js', __FILE__)); 47 } else { 48 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/admin.min.js', __FILE__)); 49 } 50 } 51 52 AutoofficeOptions::aopf($is_admin_page); 31 AutoofficeOptions::aopf(); 53 32 54 33 } else { 55 56 if (empty(AOPF_DEBUG)) {57 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/core.css', __FILE__));58 } else {59 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/core.min.css', __FILE__));60 }61 34 62 if (!empty(AOPF_DEBUG)) {63 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/core.js', __FILE__));64 } else {65 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/core.min.js', __FILE__));66 }67 68 69 35 AutoofficeWork::aopf()->aopf_autooffice_wpForm(); 70 36 } -
autooffice/trunk/includes/AutoofficeModel.php
r2019049 r2108980 2 2 class AutoofficeModel 3 3 { 4 p rotected$data = ['post' => [], 'select' => []];4 public $data = ['post' => [], 'select' => []]; 5 5 protected $rule = []; 6 6 public $db_name = 'aopf_autooffice_settings'; … … 188 188 189 189 $param = '['.$type.']['.self::aopf_autooffice_HashValue($key).']'; 190 191 if (!session_id()) { 192 session_start(); 193 } 194 190 195 191 if (!empty($value)) { 196 192 unset($_SESSION[$param]); … … 290 286 public function aopf_autooffice_parserForm($form) 291 287 { 292 288 $this->data = self::aopf_autooffice_getData(); 289 290 $new_form = false; 293 291 preg_match('/action=[\"|\'](.*?)[\"|\']/i', $form, $array); 294 292 if (empty($array[1])) { … … 297 295 } 298 296 299 $data_url = parse_url($array[1]); 300 if (!empty($data_url)) { 301 $action = $data_url['scheme'].'://'; 302 $action .= preg_replace('/^(.*?)[\.]/i', $this->data['select']['stores_name']['value'].'.', $data_url['host']).$data_url['path'].'?'; 303 $query = explode('&', $data_url['query']); 304 if (!empty($query) && is_array($query)) { 305 foreach ($query as $key => $value) { 306 if (!empty($value)) { 307 if (!empty($key)) { 308 $value = '&'.$value; 309 } 310 311 if (preg_match('/(id=)/i', $value)) { 312 $action .= '&id='.$this->data['select']['stores_id']['value']; 313 } else { 314 $action .= $value; 297 if ( 298 !empty($this->data['select']['stores_name']) && 299 !empty($this->data['select']['stores_id']) 300 ) { 301 302 $data_url = parse_url($array[1]); 303 if (!empty($data_url)) { 304 $action = $data_url['scheme'].'://'; 305 $action .= preg_replace('/^(.*?)[\.]/i', $this->data['select']['stores_name']['value'].'.', $data_url['host']).$data_url['path'].'?'; 306 $query = explode('&', $data_url['query']); 307 if (!empty($query) && is_array($query)) { 308 foreach ($query as $key => $value) { 309 if (!empty($value)) { 310 if (!empty($key)) { 311 $value = '&'.$value; 312 } 313 314 if (preg_match('/(id=)/i', $value)) { 315 $action .= '&id='.$this->data['select']['stores_id']['value']; 316 } else { 317 $action .= $value; 318 } 315 319 } 316 320 } 317 } 321 } else { 322 $action = false; 323 } 324 } 325 326 if (empty($action)) { 327 $action = 'https://'.$this->data['select']['stores_name']['value'].'.aoserver.ru/?r=personal/newsletter/subscriptions/add&id='.$this->data['select']['stores_id']['value'].'&lg=ru'; 328 } 329 } 330 331 if (!empty($this->data['select']['newsletter'])) { 332 333 $new_form = preg_replace('/action=[\"|\'](.*?)[\"|\']/i', 'action="'.$action.'"', $form); 334 if (!preg_match('/name=[\"|\']Contact\[id_newsletter\][\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', $form)) { 335 self::aopf_autooffice_setSession('error', 'All', __('Error_message_2', 'autooffice')); 336 return $form; 337 } 338 $new_form = preg_replace('/name=[\"|\']Contact\[id_newsletter\][\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', 'name="Contact[id_newsletter]" value="'.$this->data['select']['newsletter']['value'].'"', $new_form); 339 } 340 341 if (!empty($this->data['select']['advertising'])) { 342 343 if (preg_match('/name=[\"|\']Contact\[id_advertising_channel_page\][\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', $form)) { 344 $new_form = preg_replace('/name=[\"|\']Contact\[id_advertising_channel_page\][\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', 'name="Contact[id_advertising_channel_page]" value="'.$this->data['select']['advertising']['value'].'"', $new_form); 318 345 } else { 319 $action = false; 320 } 321 } 322 323 if (empty($action)) { 324 $action = 'https://'.$this->data['select']['stores_name']['value'].'.aoserver.ru/?r=personal/newsletter/subscriptions/add&id='.$this->data['select']['stores_id']['value'].'&lg=ru'; 325 } 326 327 $new_form = preg_replace('/action=[\"|\'](.*?)[\"|\']/i', 'action="'.$action.'"', $form); 328 if (!preg_match('/name=[\"|\']Contact\[id_newsletter\][\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', $form)) { 329 self::aopf_autooffice_setSession('error', 'All', __('Error_message_2', 'autooffice')); 330 return $form; 331 } 332 $new_form = preg_replace('/name=[\"|\']Contact\[id_newsletter\][\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', 'name="Contact[id_newsletter]" value="'.$this->data['select']['newsletter']['value'].'"', $new_form); 333 334 335 if (preg_match('/name=[\"|\']Contact\[id_advertising_channel_page\][\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', $form)) { 336 $new_form = preg_replace('/name=[\"|\']Contact\[id_advertising_channel_page\][\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', 'name="Contact[id_advertising_channel_page]" value="'.$this->data['select']['advertising']['value'].'"', $new_form); 337 } else { 338 if (!empty($this->data['select']['advertising']['value'])) { 339 self::aopf_autooffice_setSession('error', 'All', __('Error_message_3', 'autooffice')); 340 return $form; 341 } 342 } 343 344 if (preg_match('/name=[\"|\']id_form[\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', $form)) { 345 $new_form = preg_replace('/name=[\"|\']id_form[\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', 'name="id_form" value="'.$this->data['select']['subsform']['value'].'"', $new_form); 346 } else { 347 if (!empty($this->data['select']['subsform']['value'])) { 348 self::aopf_autooffice_setSession('error', 'All', __('Error_message_4', 'autooffice')); 349 return $form; 346 if (!empty($this->data['select']['advertising']['value'])) { 347 self::aopf_autooffice_setSession('error', 'All', __('Error_message_3', 'autooffice')); 348 return $form; 349 } 350 } 351 } 352 353 if (!empty($this->data['select']['subsform'])) { 354 355 if (preg_match('/name=[\"|\']id_form[\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', $form)) { 356 $new_form = preg_replace('/name=[\"|\']id_form[\"|\'][\s]{1,}value=[\"|\'](.*?)[\"|\']/i', 'name="id_form" value="'.$this->data['select']['subsform']['value'].'"', $new_form); 357 } else { 358 if (!empty($this->data['select']['subsform']['value'])) { 359 self::aopf_autooffice_setSession('error', 'All', __('Error_message_4', 'autooffice')); 360 return $form; 361 } 350 362 } 351 363 } … … 382 394 * dataAcquisition($rule) 383 395 */ 384 p rotectedfunction aopf_autooffice_dataAcquisition($rule)396 public function aopf_autooffice_dataAcquisition($rule) 385 397 { 386 398 global $wpdb; … … 430 442 } 431 443 } 432 444 433 445 if (!empty($_GET['page']) && preg_match('/autooffice/i', $_GET['page'])) { 434 446 $this->data['load'] = self::aopf_autooffice_getLoadData(); -
autooffice/trunk/includes/AutoofficeOptions.php
r2024705 r2108980 21 21 protected $html_position = 1; 22 22 protected $data = []; 23 protected $is_plugin_page; 23 24 24 25 public function __construct() … … 92 93 public function aopf_autooffice_settings_page() 93 94 { 95 self::resourceRegistration(); 96 94 97 if (empty($model) || get_class($model)!='AutoofficeModel') { 95 98 $model = new AutoofficeModel(); … … 118 121 public function aopf_autooffice_settings_page_html() 119 122 { 123 self::resourceRegistration(); 124 120 125 if (empty($model) || get_class($model)!='AutoofficeModel') { 121 126 $model = new AutoofficeModel(); … … 143 148 public function aopf_autooffice_settings_page_css() 144 149 { 150 self::resourceRegistration(); 151 145 152 if (empty($model) || get_class($model)!='AutoofficeModel') { 146 153 $model = new AutoofficeModel(); … … 168 175 public function aopf_autooffice_settings_page_js() 169 176 { 177 self::resourceRegistration(); 178 170 179 if (empty($model) || get_class($model)!='AutoofficeModel') { 171 180 $model = new AutoofficeModel(); … … 185 194 } else { 186 195 require_once(AOPF_AUTOOFFICE_DIR.'views/plugin_settings_page_js.php'); 196 } 197 } 198 199 /** 200 * resourceRegistration() 201 */ 202 public function resourceRegistration() 203 { 204 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/bootstrap.min.css', dirname(__FILE__))); 205 206 if (empty(AOPF_DEBUG)) { 207 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/admin.css', dirname(__FILE__))); 208 } else { 209 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/admin.min.css', dirname(__FILE__))); 210 } 211 212 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/bootstrap.min.js', dirname(__FILE__))); 213 214 if (!empty(AOPF_DEBUG)) { 215 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/admin.js', dirname(__FILE__))); 216 } else { 217 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/admin.min.js', dirname(__FILE__))); 187 218 } 188 219 } … … 215 246 * model($className=__CLASS__) 216 247 */ 217 public static function aopf($ is_plugin_page, $className=__CLASS__)218 { 219 return new $className( $is_plugin_page);248 public static function aopf($className=__CLASS__) 249 { 250 return new $className(); 220 251 } 221 252 } -
autooffice/trunk/includes/AutoofficeWork.php
r2019049 r2108980 15 15 public function aopf_autooffice_form() 16 16 { 17 self::resourceRegistration(); 18 17 19 if (empty($model) || get_class($model)!='AutoofficeModel') { 18 20 $model = new AutoofficeModel(); … … 34 36 35 37 /** 38 * resourceRegistration() 39 */ 40 public function resourceRegistration() 41 { 42 if (empty(AOPF_DEBUG)) { 43 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/core.css', __FILE__)); 44 } else { 45 wp_enqueue_style('aopf_plugin_css', plugins_url('assets/css/core.min.css', __FILE__)); 46 } 47 48 if (!empty(AOPF_DEBUG)) { 49 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/core.js', __FILE__)); 50 } else { 51 wp_enqueue_script('aopf_plugin_js', plugins_url('assets/js/core.min.js', __FILE__)); 52 } 53 } 54 55 /** 36 56 * model($className=__CLASS__) 37 57 */ -
autooffice/trunk/readme.txt
r2105526 r2108980 3 3 Tags: autoofficeemail 4 4 Requires at least: 4.9.9 5 Tested up to: 5.2. 15 Tested up to: 5.2.2 6 6 Requires PHP: 5.6.31 7 Stable tag: 1.0.0 17 Stable tag: 1.0.02 8 8 9 9 Плагин для интеграции рассылки с сервисом АвтоОфис -
autooffice/trunk/views/plugin_settings_page.php
r2019049 r2108980 74 74 </label> 75 75 <div class="col-sm-8"> 76 <input type="number" min="1" name="Autooffice[stores_id]" id="Autooffice_stores_id" value="<?= $this->data['post']['stores_id']['value']? $this->data['post']['stores_id']['value'] : $this->data['select']['stores_id']['value']?>" class="form-control" <?=$this->data['select']['api_key']['required'] ? 'required' : ''?>>76 <input type="number" min="1" name="Autooffice[stores_id]" id="Autooffice_stores_id" value="<?=!empty($this->data['post']['stores_id']['value']) ? $this->data['post']['stores_id']['value'] : $this->data['select']['stores_id']['value']?>" class="form-control" <?=$this->data['select']['api_key']['required'] ? 'required' : ''?>> 77 77 <?=AutoofficeModel::aopf()->aopf_autooffice_hasSession('error', 'stores_id') ? '<div class="alert alert-danger">'.AutoofficeModel::aopf()->aopf_autooffice_getSession('error', 'stores_id').'</div>' : ''?> 78 78 </div> … … 83 83 </label> 84 84 <div class="col-sm-8"> 85 <input type="text" maxlength="225" name="Autooffice[stores_name]" id="Autooffice_stores_name" value="<?= $this->data['post']['stores_name']['value']? $this->data['post']['stores_name']['value'] : $this->data['select']['stores_name']['value']?>" class="form-control" <?=$this->data['select']['stores_name']['required'] ? 'required' : ''?>>85 <input type="text" maxlength="225" name="Autooffice[stores_name]" id="Autooffice_stores_name" value="<?=!empty($this->data['post']['stores_name']['value']) ? $this->data['post']['stores_name']['value'] : $this->data['select']['stores_name']['value']?>" class="form-control" <?=$this->data['select']['stores_name']['required'] ? 'required' : ''?>> 86 86 <?=AutoofficeModel::aopf()->aopf_autooffice_hasSession('error', 'stores_name') ? '<div class="alert alert-danger">'.AutoofficeModel::aopf()->aopf_autooffice_getSession('error', 'stores_name').'</div>' : ''?> 87 87 </div> … … 92 92 </label> 93 93 <div class="col-sm-8"> 94 <input type="text" maxlength="225" name="Autooffice[api_key]" id="Autooffice_api_key" value="<?= $this->data['post']['api_key']['value']? $this->data['post']['api_key']['value'] : $this->data['select']['api_key']['value']?>" class="form-control" <?=$this->data['select']['api_key']['required'] ? 'required' : ''?>>94 <input type="text" maxlength="225" name="Autooffice[api_key]" id="Autooffice_api_key" value="<?=!empty($this->data['post']['api_key']['value']) ? $this->data['post']['api_key']['value'] : $this->data['select']['api_key']['value']?>" class="form-control" <?=$this->data['select']['api_key']['required'] ? 'required' : ''?>> 95 95 <?=AutoofficeModel::aopf()->aopf_autooffice_hasSession('error', 'api_key') ? '<div class="alert alert-danger">'.AutoofficeModel::aopf()->aopf_autooffice_getSession('error', 'api_key').'</div>' : ''?> 96 96 </div> -
autooffice/trunk/views/plugin_settings_page_css.php
r2019049 r2108980 40 40 </label> 41 41 <div class="col-sm-12"> 42 <textarea style="font-size:13px" name="Autooffice[form_css]" id="Autooffice_form_css" class="form-control" rows="20" <?= $this->data['select']['form_css']['required'] ? 'required' : ''?>><?=$this->data['post']['form_css']['value']? $this->data['post']['form_css']['value'] : $this->data['select']['form_css']['value']?></textarea>42 <textarea style="font-size:13px" name="Autooffice[form_css]" id="Autooffice_form_css" class="form-control" rows="20" <?=!empty($this->data['select']['form_css']['required']) ? 'required' : ''?>><?=!empty($this->data['post']['form_css']['value']) ? $this->data['post']['form_css']['value'] : $this->data['select']['form_css']['value']?></textarea> 43 43 <?=AutoofficeModel::aopf()->aopf_autooffice_hasSession('error', 'form_css') ? '<div class="alert alert-danger">'.AutoofficeModel::aopf()->aopf_autooffice_getSession('error', 'form_css').'</div>' : ''?> 44 44 </div> -
autooffice/trunk/views/plugin_settings_page_html.php
r2019049 r2108980 16 16 add_action('admin_footer', 'aopf_autooffice_page_settings_html'); 17 17 18 $form = $this->data['post']['form_html']['value']? $this->data['post']['form_html']['value'] : $this->data['select']['form_html']['value'];18 $form = !empty($this->data['post']['form_html']['value']) ? $this->data['post']['form_html']['value'] : $this->data['select']['form_html']['value']; 19 19 $form = AutoofficeModel::aopf()->aopf_autooffice_parserForm($form); 20 20 ?> -
autooffice/trunk/views/plugin_settings_page_js.php
r2019049 r2108980 40 40 </label> 41 41 <div class="col-sm-12"> 42 <textarea style="font-size:13px" name="Autooffice[form_js]" id="Autooffice_form_js" class="form-control" rows="20" <?= $this->data['select']['form_js']['required'] ? 'required' : ''?>><?=$this->data['post']['form_js']['value']? $this->data['post']['form_js']['value'] : $this->data['select']['form_js']['value']?></textarea>42 <textarea style="font-size:13px" name="Autooffice[form_js]" id="Autooffice_form_js" class="form-control" rows="20" <?=!empty($this->data['select']['form_js']['required']) ? 'required' : ''?>><?=!empty($this->data['post']['form_js']['value']) ? $this->data['post']['form_js']['value'] : $this->data['select']['form_js']['value']?></textarea> 43 43 <?=AutoofficeModel::aopf()->aopf_autooffice_hasSession('error', 'form_js') ? '<div class="alert alert-danger">'.AutoofficeModel::aopf()->aopf_autooffice_getSession('error', 'form_js').'</div>' : ''?> 44 44 </div>
Note: See TracChangeset
for help on using the changeset viewer.