This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
extensions.php
815 lines (696 loc) · 25.7 KB
/
extensions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
<?php
/** no direct access **/
defined('_WPLEXEC') or die('Restricted access');
/**
* Extensions Library
* @author Howard <[email protected]>
* @package WPL
* @since 1.0.0
*/
class wpl_extensions
{
/**
*
* @var objects
*/
public $extensions;
/**
* For getting an extension
* @author Howard <[email protected]>
* @param int $extension_id
* @return object
*/
public function get_extension($extension_id)
{
return wpl_db::get('*', 'wpl_extensions', 'id', $extension_id);
}
/**
* For getting extensions
* @author Howard <[email protected]>
* @param int $enabled
* @param string $type
* @param int $client
* @return objects
*/
public function get_extensions($enabled = 1, $type = '', $client = '')
{
$query = "SELECT * FROM `#__wpl_extensions` WHERE `enabled`>='$enabled' ".(trim($type) != '' ? "AND `type`='$type'" : "")." ".(trim($client) != '' ? "AND (`client`='$client' OR `client`='2')" : "")." ORDER BY `index` ASC";
$this->extensions = wpl_db::select($query);
return $this->extensions;
}
/**
* For importing extensions automatically
* @author Howard <[email protected]>
* @return void
*/
public function import_extensions()
{
if(!$this->extensions) return;
foreach($this->extensions as $extension)
{
if($extension->type == 'action') $this->import_action($extension);
elseif($extension->type == 'shortcode') $this->import_shortcode($extension);
elseif($extension->type == 'library') $this->import_library($extension);
elseif($extension->type == 'widget') $this->import_widget($extension);
elseif($extension->type == 'service') $this->import_service($extension);
elseif($extension->type == 'sidebar') $this->import_sidebar($extension);
}
}
/**
* Returns extension types
* @author Howard <[email protected]>
* @param int $enabled
* @return objects
*/
public function get_extensions_types($enabled = 0)
{
$query = "SELECT `id`, `type` FROM `#__wpl_extensions` WHERE `enabled`>='$enabled' GROUP BY `type` ORDER BY `type` ASC";
return wpl_db::select($query);
}
/**
* for importing actions
* @author Howard <[email protected]>
* @param object $extension
* @return void
*/
public function import_action($extension)
{
$priority = trim($extension->param3) != '' ? $extension->param3 : 10;
$args = trim($extension->param4) != '' ? $extension->param4 : 1;
if(strpos($extension->param2, '->') === false)
{
add_action($extension->param1, $extension->param2, $priority, $args);
}
else
{
$ex = explode('->', $extension->param2);
$class_name = $ex[0];
/** generate object **/
$class_obj = new $class_name();
$function_name = $ex[1];
add_action($extension->param1, array($class_obj, $function_name), $priority, $args);
}
}
/**
* Imports a shortcode
* @author Howard <[email protected]>
* @param object $extension
* @return void
*/
public function import_shortcode($extension)
{
if(strpos($extension->param2, '->') === false)
{
add_shortcode($extension->param1, $extension->param2);
}
else
{
$ex = explode('->', $extension->param2);
$class_name = $ex[0];
/** generate object **/
$class_obj = new $class_name();
$function_name = $ex[1];
add_shortcode($extension->param1, array($class_obj, $function_name));
}
}
/**
* Imports a stylesheet
* @author Howard <[email protected]>
* @param object $extension
* @return void
*/
public static function import_style($extension)
{
/** render style_url **/
$style_url = (isset($extension->external) or (isset($extension->param5) and trim($extension->param5))) ? $extension->param2 : wpl_global::get_wpl_asset_url($extension->param2);
if(trim($extension->param2) != '') wp_register_style($extension->param1, $style_url);
wp_enqueue_style($extension->param1);
}
/**
* Import a JS file
* @author Howard <[email protected]>
* @param object $extension
* @param boolean $footer
* @return void
*/
public static function import_javascript($extension, $footer = false)
{
/** render script_url **/
$script_url = (isset($extension->external) or (isset($extension->param5) and trim($extension->param5))) ? $extension->param2 : wpl_global::get_wpl_asset_url($extension->param2);
$in_footer = (isset($extension->param4) and trim($extension->param4)) ? $extension->param4 : $footer;
if(trim($extension->param2) != '') wp_register_script($extension->param1, $script_url, array(), false, $in_footer);
wp_enqueue_script($extension->param1);
}
/**
* Include a PHP library
* @author Howard <[email protected]>
* @param object $extension
* @return void
*/
public function import_library($extension)
{
$function_name = $extension->param2;
$function_name($extension->param1);
}
/**
* Imports a widget
* @author Howard <[email protected]>
* @param object $extension
* @return void
*/
public function import_widget($extension)
{
$path = _wpl_import($extension->param1, true, true);
if(wpl_file::exists($path))
{
require_once $path;
add_action($extension->param2, create_function('', 'register_widget("'.$extension->param3.'");'));
}
}
/**
* Imports a service
* @author Howard <[email protected]>
* @param object $extension
* @return boolean
*/
public function import_service($extension)
{
$ex = explode('->', $extension->param2);
$class_file = $ex[0];
$class_name = 'wpl_service_'.$ex[0];
/** first validation **/
if(trim($class_file) == '') return false;
/** generate object **/
_wpl_import('libraries.services.'.$class_file);
/** return if service file is not exists **/
if(!class_exists($class_name)) return false;
$class_obj = new $class_name();
$function_name = $ex[1];
$priority = trim($extension->param3) != '' ? $extension->param3 : 10;
add_action($extension->param1, array($class_obj, $function_name), $priority);
}
/**
* Imports a language file
* @author Howard <[email protected]>
* @return void
*/
public function import_language()
{
$locale = apply_filters('plugin_locale', get_locale(), WPL_TEXTDOMAIN);
$overriden_language_filepath = WP_LANG_DIR .DS. WPL_BASENAME .DS. WPL_TEXTDOMAIN.'-'.$locale.'.mo';
$overriden_language_filepath = wpl_path::clean($overriden_language_filepath);
/** check if the language file is overridden **/
if(wpl_file::exists($overriden_language_filepath))
{
load_textdomain(WPL_TEXTDOMAIN, WP_LANG_DIR .DS. WPL_BASENAME .DS. WPL_TEXTDOMAIN.'-'.$locale.'.mo');
}
else
{
load_plugin_textdomain(WPL_TEXTDOMAIN, false, WPL_BASENAME . DS . 'languages');
}
}
/**
* For importing permalink
* @author Howard <[email protected]>
* @return void
*/
public function import_permalink()
{
add_action('wp_loaded', array($this, 'wpl_flush_rules'), 1);
add_filter('rewrite_rules_array', array($this, 'wpl_insert_rewrite_rules'));
add_filter('query_vars', array($this, 'wpl_insert_query_vars'));
$sef = new wpl_sef();
add_shortcode('WPL', array($sef, 'process'));
}
/**
* For importing sidebar
* @author Howard <[email protected]>
* @param object $extension
* @return void
*/
public function import_sidebar($extension)
{
$name = (isset($extension->title) and trim($extension->title)) ? $extension->title : 'WPL sidebar';
$id = (isset($extension->param1) and trim($extension->param1)) ? $extension->param1 : 'wpl-sidebar-id';
$description = (isset($extension->description) and trim($extension->description)) ? $extension->description : 'WPL sidebar description';
$before_widget = (isset($extension->param2) and trim($extension->param2)) ? $extension->param2 : '<aside id="%1$s" class="widget %2$s">';
$after_widget = (isset($extension->param3) and trim($extension->param3)) ? $extension->param3 : '</aside>';
$before_title = (isset($extension->param4) and trim($extension->param4)) ? $extension->param4 : '<h3 class="widget-title">';
$after_title = (isset($extension->param5) and trim($extension->param5)) ? $extension->param5 : '</h3>';
register_sidebar(array(
'name' => __($name, WPL_TEXTDOMAIN),
'id' => $id,
'description' => __($description, WPL_TEXTDOMAIN),
'before_widget' => $before_widget,
'after_widget' => $after_widget,
'before_title' => $before_title,
'after_title' => $after_title,
));
}
/**
* Flushes Rewrite rules if WPL rules are not yet included
* @author Howard <[email protected]>
* @global object $wp_rewrite
* @return void
*/
public function wpl_flush_rules()
{
$rules = get_option('rewrite_rules');
$wpl_rules = wpl_sef::get_main_rewrite_rule();
$flushed = false;
foreach($wpl_rules as $wpl_rule)
{
if($flushed or isset($rules[$wpl_rule['regex']])) continue;
global $wp_rewrite;
$wp_rewrite->flush_rules();
$flushed = true;
}
}
/**
* Adds WPL rewrite rukes
* @author Howard <[email protected]>
* @param array $rules
* @return array
*/
public function wpl_insert_rewrite_rules($rules)
{
$wpl_rules = wpl_sef::get_main_rewrite_rule();
$newrules = array();
foreach($wpl_rules as $wpl_rule) $newrules[$wpl_rule['regex']] = $wpl_rule['url'];
return $newrules + $rules;
}
/**
* Adding the wpl query string var so that WP recognizes it
* @author Howard <[email protected]>
* @param array $vars
* @return array
*/
public function wpl_insert_query_vars($vars)
{
array_push($vars, 'wpl_qs');
return $vars;
}
/**
* Adding wpl TinyMCE buttons
* @author Howard <[email protected]>
*/
public function import_mce_buttons()
{
if(current_user_can('edit_posts') or current_user_can('edit_pages'))
{
add_filter('mce_external_plugins', array($this, 'register_shortcode_buttons'));
add_filter('mce_buttons', array($this, 'add_shortcode_wizard'));
}
}
/**
* Adding shortcode wizard
* @author Howard <[email protected]>
* @param array $buttons
* @return array
*/
public function add_shortcode_wizard($buttons)
{
array_push($buttons, 'wplshortcode');
return $buttons;
}
/**
* Registering shortcode buttons
* @author Howard <[email protected]>
* @param array $plugin_array
* @return array
*/
public function register_shortcode_buttons($plugin_array)
{
$plugin_array['wplbuttons'] = wpl_global::get_wpl_asset_url('packages/mce_editor/wpl.js');
return $plugin_array;
}
/**
* Registering active and deactive functions for WPl
* @author Howard <[email protected]>
* @return void
*/
public function wpl_active_deactive()
{
register_activation_hook(WPL_ABSPATH.'WPL.php', array($this, 'activate_wpl'));
register_deactivation_hook(WPL_ABSPATH.'WPL.php', array($this, 'deactivate_wpl'));
register_uninstall_hook(WPL_ABSPATH.'WPL.php', array('wpl_extensions', 'uninstall_wpl'));
}
/**
* Running installation queries and initializing WPL
* @author Howard <[email protected]>
* @param boolean $network_activate
* @return void
*/
public function activate_wpl($network_activate = false)
{
/** Call Franchise activate function **/
if(wpl_global::is_multisite())
{
$fswpl = new wpl_addon_franchise_wpl();
return $fswpl->activate($network_activate);
}
if(wpl_folder::exists(WPL_ABSPATH. 'assets' .DS. 'install' .DS. 'files'))
{
/** copy files **/
$res = wpl_folder::copy(WPL_ABSPATH. 'assets' .DS. 'install' .DS. 'files', ABSPATH, '', true);
/** delete files **/
wpl_folder::delete(WPL_ABSPATH. 'assets' .DS. 'install' .DS. 'files');
}
/** run queries **/
$query_file = WPL_ABSPATH. 'assets' .DS. 'install' .DS. 'queries.sql';
if(wpl_file::exists($query_file))
{
$queries = wpl_file::read($query_file);
$queries = str_replace(";\r\n", "-=++=-", $queries);
$queries = str_replace(";\r", "-=++=-", $queries);
$queries = str_replace(";\n", "-=++=-", $queries);
$sqls = explode("-=++=-", $queries);
foreach($sqls as $sql)
{
try{wpl_db::q($sql);} catch (Exception $e){}
}
/** delete query file **/
wpl_file::delete($query_file);
}
/** run script **/
$script_file = WPL_ABSPATH. 'assets' .DS. 'install' .DS. 'script.php';
if(wpl_file::exists($script_file))
{
include $script_file;
/** delete script file **/
wpl_file::delete($script_file);
}
/** create propertylisting page **/
$pages = array('Properties'=>'[WPL]', 'For Sale'=>'[WPL sf_select_listing="9"]', 'For Rent'=>'[WPL sf_select_listing="10"]', 'Vacation Rental'=>'[WPL sf_select_listing="12"]');
foreach($pages as $title=>$content)
{
if(wpl_db::select("SELECT COUNT(post_content) FROM `#__posts` WHERE `post_content` LIKE '%$content%' AND `post_status` IN ('publish', 'private')", 'loadResult') != 0) continue;
$post = array('post_title'=>$title, 'post_content'=>$content, 'post_type'=>'page', 'post_status'=>'publish', 'comment_status'=>'closed', 'ping_status'=>'closed', 'post_author'=>1);
$post_id = wp_insert_post($post);
if($content == '[WPL]')
{
_wpl_import('libraries.settings');
wpl_settings::save_setting('main_permalink', $post_id);
}
}
/** Add admin user to WPL **/
wpl_users::add_user_to_wpl(wpl_users::get_blog_admin_id());
/** upgrade WPL **/
self::upgrade_wpl();
}
/**
* Running necesarry queries and functions for upgrading
* @author Howard <[email protected]>
* @return void
*/
public function upgrade_wpl()
{
/** Call Franchise upgrade function **/
if(wpl_global::is_multisite())
{
$fswpl = new wpl_addon_franchise_wpl();
return $fswpl->upgrade();
}
if(wpl_folder::exists(WPL_ABSPATH. 'assets' .DS. 'upgrade' .DS. 'files'))
{
/** copy files **/
$res = wpl_folder::copy(WPL_ABSPATH. 'assets' .DS. 'upgrade' .DS. 'files', ABSPATH, '', true);
/** delete files **/
wpl_folder::delete(WPL_ABSPATH. 'assets' .DS. 'upgrade' .DS. 'files');
}
/** run queries **/
$query_file = WPL_ABSPATH. 'assets' .DS. 'upgrade' .DS. 'queries.sql';
if(wpl_file::exists($query_file))
{
$queries = wpl_file::read($query_file);
$queries = str_replace(";\r\n", "-=++=-", $queries);
$queries = str_replace(";\r", "-=++=-", $queries);
$queries = str_replace(";\n", "-=++=-", $queries);
$sqls = explode("-=++=-", $queries);
foreach($sqls as $sql)
{
try{wpl_db::q($sql);} catch (Exception $e){}
}
/** delete query file **/
wpl_file::delete($query_file);
}
/** run script **/
$script_file = WPL_ABSPATH. 'assets' .DS. 'upgrade' .DS. 'script.php';
if(wpl_file::exists($script_file))
{
include $script_file;
/** delete script file **/
wpl_file::delete($script_file);
}
/** update WPL version in db **/
update_option('wpl_version', wpl_global::wpl_version());
}
/**
* Deactivating WPL
* @author Howard <[email protected]>
* @param boolean $network_deactivate
*/
public function deactivate_wpl($network_deactivate = false)
{
/** Call Franchise deactivate function **/
if(wpl_global::is_multisite())
{
$fswpl = new wpl_addon_franchise_wpl();
return $fswpl->deactivate($network_deactivate);
}
}
/**
* Uninstalling WPL
* @author Howard <[email protected]>
* @return boolean
*/
public static function uninstall_wpl()
{
$tables = wpl_db::select('SHOW TABLES');
$database = wpl_db::get_DBO();
foreach($tables as $table_name=>$table)
{
if(strpos($table_name, $database->prefix.'wpl_') !== false)
{
/** drop table **/
wpl_db::q("DROP TABLE `$table_name`");
}
}
/** delete options **/
wpl_db::q("DELETE FROM `#__options` WHERE `option_name` LIKE 'wpl_%' AND `option_name` NOT LIKE 'wpl_theme%'", 'delete');
$upload_path = wpl_global::get_upload_base_path();
if(wpl_file::exists($upload_path)) wpl_file::delete($upload_path);
/** Call Franchise uninstall function **/
if(wpl_global::is_multisite())
{
$fswpl = new wpl_addon_franchise_wpl();
$fswpl->uninstall();
}
return true;
}
/**
* Adding js dynamic vars to the head of page
* @author Howard <[email protected]>
* @return void
*/
public function import_dynamic_js()
{
echo '<script type="text/javascript">';
echo 'wpl_baseUrl="'.wpl_global::get_wordpress_url().'";';
echo 'wpl_baseName="'.WPL_BASENAME.'";';
echo '</script>';
}
/**
* Adding js dynamic vars to the head of page
* @author Howard <[email protected]>
* @param object $wp_admin_bar
* @return void
*/
public function plus_new_menu($wp_admin_bar)
{
$cur_user_id = wpl_users::get_cur_user_id();
$cur_user_data = wpl_users::get_user($cur_user_id);
if(wpl_users::is_administrator($cur_user_id) or isset($cur_user_data->data->wpl_data->id))
{
$wp_admin_bar->add_menu(array(
'id'=>'wpl_add_listings',
'title'=>__('WPL Listing', WPL_TEXTDOMAIN),
'parent'=>'new-content',
'href'=>'admin.php?page=wpl_admin_add_listing'
));
}
}
/**
* @deprecated
*/
public function wpl_admin_pages()
{
self::wpl_admin_menus();
}
/**
* For creating admin menus
* @author Howard <[email protected]>
*/
public function wpl_admin_menus()
{
$cur_user_id = wpl_users::get_cur_user_id();
$cur_user_data = wpl_users::get_user($cur_user_id);
$cur_role = wpl_users::get_role($cur_user_id, false);
$wpl_roles = wpl_users::get_wpl_roles();
$menus = wpl_global::get_menus('menu', 'backend');
$submenus = wpl_global::get_menus('submenu', 'backend');
/** generate pages object **/
$controller = new wpl_controller();
if(wpl_users::is_administrator($cur_user_id) or isset($cur_user_data->data->wpl_data->id))
{
/** add menus **/
foreach($menus as $menu)
{
$role = $menu->capability == 'current' ? $cur_role : $wpl_roles[$menu->capability];
$position = $menu->position ? $menu->position : NULL;
add_menu_page(__($menu->page_title, WPL_TEXTDOMAIN), __($menu->menu_title, WPL_TEXTDOMAIN), $role, $menu->menu_slug, array($controller, $menu->function), '', $position);
}
/** add sub menus **/
foreach($submenus as $submenu)
{
if(!wpl_users::has_menu_access($submenu->menu_slug, $cur_user_id)) continue;
$role = $submenu->capability == 'current' ? $cur_role : $wpl_roles[$submenu->capability];
$menu_title = $submenu->separator ? $controller->wpl_add_separator().__($submenu->menu_title, WPL_TEXTDOMAIN) : __($submenu->menu_title, WPL_TEXTDOMAIN);
add_submenu_page($submenu->parent, __($submenu->page_title, WPL_TEXTDOMAIN), $menu_title, $role, $submenu->menu_slug, array($controller, $submenu->function));
}
}
}
/**
* For creating admin bar menu
* @author Howard <[email protected]>
* @global object $wp_admin_bar
*/
public function wpl_admin_bar_menu()
{
/** Don't show top bar menu on network admin **/
if(is_network_admin()) return false;
$cur_user_id = wpl_users::get_cur_user_id();
$cur_user_data = wpl_users::get_user($cur_user_id);
$menus = wpl_global::get_menus('menu', 'backend');
$submenus = wpl_global::get_menus('submenu', 'backend');
global $wp_admin_bar;
/** generate pages object **/
$controller = new wpl_controller();
if(wpl_users::is_administrator($cur_user_id) or isset($cur_user_data->data->wpl_data->id))
{
/** add menus **/
foreach($menus as $menu)
{
$menu_slug = (!wpl_users::is_administrator($cur_user_id) and $menu->capability != 'current') ? 'wpl_admin_profile' : $menu->menu_slug;
$wp_admin_bar->add_menu(array(
'id'=>$menu->menu_slug,
'title'=>__($menu->menu_title, WPL_TEXTDOMAIN),
'href'=>wpl_global::get_wp_admin_url().'admin.php?page='.$menu_slug,
));
}
/** add sub menus **/
foreach($submenus as $submenu)
{
if(!wpl_users::has_menu_access($submenu->menu_slug)) continue;
if(!wpl_users::is_administrator($cur_user_id) and $submenu->capability != 'current') continue;
$menu_title = $submenu->separator ? $controller->wpl_add_separator().__($submenu->menu_title, WPL_TEXTDOMAIN) : __($submenu->menu_title, WPL_TEXTDOMAIN);
$wp_admin_bar->add_menu(array(
'id'=>$submenu->menu_slug,
'parent'=>$submenu->parent,
'title'=>$menu_title,
'href'=>wpl_global::get_wp_admin_url().'admin.php?page='.$submenu->menu_slug,
));
}
}
}
/**
* for adding page number to listing pages
* @author Howard <[email protected]>
* @param string $title
* @return string
*/
public function wp_title($title)
{
$wplview = wpl_request::getVar('wplview');
$wplpage = wpl_request::getVar('wplpage');
if(in_array($wplview, array('property_listing', 'profile_listing')) and $wplpage >= 2)
{
/** has HTML tag **/
if(strpos($title, '</') != false) return $title;
return wpl_global::clean($title.' -- '.__('Page', WPL_TEXTDOMAIN).' '.$wplpage);
}
return $title;
}
/**
* For adding styles and scripts
* @author Howard <[email protected]>
* @return void
*/
public static function import_styles_scripts()
{
$wpl_extensions = new wpl_extensions();
$javascripts = $wpl_extensions->get_extensions(1, 'javascript', wpl_global::get_client());
foreach($javascripts as $javascript)
{
$wpl_extensions->import_javascript($javascript);
}
$styles = $wpl_extensions->get_extensions(1, 'style', wpl_global::get_client());
foreach($styles as $style)
{
$wpl_extensions->import_style($style);
}
}
/**
*
* @author Howard <[email protected]>
* @param array $links
* @param string $file
* @return array
*/
public static function wpl_plugin_links($links, $file)
{
if(strpos($file, WPL_BASENAME) !== false)
{
$links[] = '<a href="'.wpl_global::get_wp_admin_url().'admin.php?page=wpl_admin_settings">'.__('Settings', WPL_TEXTDOMAIN).'</a>';
$links[] = '<a href="http://wpl.realtyna.com/wassets/wpl-manual.pdf" target="_blank">'.__('WPL Manual', WPL_TEXTDOMAIN).'</a>';
$links[] = '<a href="http://wpl.realtyna.com/redirect.php?action=shop" target="_blank">'.__('WPL Add-ons', WPL_TEXTDOMAIN).'</a>';
}
return $links;
}
}
/** load extensions **/
$wpl_extensions = new wpl_extensions();
/** active deactive functions **/
$wpl_extensions->wpl_active_deactive();
/** include some addon libraries **/
_wpl_import('libraries.addon_pro');
_wpl_import('libraries.addon_franchise');
if(!(isset($GLOBALS['pagenow']) and $GLOBALS['pagenow'] == 'plugins.php' and wpl_request::getVar('action') == 'activate') and !(wpl_request::getVar('tgmpa-activate') == 'activate-plugin'))
{
$wpl_extensions->get_extensions(1, '', wpl_global::get_client());
$wpl_extensions->import_extensions();
if(version_compare(wpl_global::get_wp_option('wpl_version'), wpl_global::wpl_version(), '<'))
{
/** upgrading WPL **/
$wpl_extensions->upgrade_wpl();
}
}
/** import TinyMCE buttons **/
add_action('init', array($wpl_extensions, 'import_mce_buttons'));
/** listing menu in +new menu **/
add_action('admin_bar_menu', array($wpl_extensions, 'plus_new_menu'), 99);
/** import dynamic js **/
add_action('wp_head', array($wpl_extensions, 'import_dynamic_js'), 1);
add_action('admin_print_scripts', array($wpl_extensions, 'import_dynamic_js'), 1);
/** add javascripts and styles **/
if(wpl_global::get_client() == '0') add_action('wp_enqueue_scripts', array($wpl_extensions, 'import_styles_scripts'), 0);
elseif(wpl_global::get_client() == '1') add_action('admin_enqueue_scripts', array($wpl_extensions, 'import_styles_scripts'), 0);
add_action('login_enqueue_scripts', array($wpl_extensions, 'import_styles_scripts'), 0);
/** filter title **/
add_filter('wp_title', array($wpl_extensions, 'wp_title'), 999);
/** import languages **/
add_action('init', array($wpl_extensions, 'import_language'));
/** plugin links **/
add_filter('plugin_row_meta', array($wpl_extensions, 'wpl_plugin_links'), 10, 2);
/** import permalink **/
$wpl_extensions->import_permalink();