This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathsimple-backup-plugin.php
More file actions
1137 lines (811 loc) · 39 KB
/
Copy pathsimple-backup-plugin.php
File metadata and controls
1137 lines (811 loc) · 39 KB
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
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
class Simple_Backup_Plugin{
//plugin version number
private $version = "2.7.11";
private $debug = false;
//holds simple security settings page class
private $settings_page;
//holds ftp tools object
private $ftp_tools;
//options are: edit, upload, link-manager, pages, comments, themes, plugins, users, tools, options-general
private $page_icon = "options-general";
//settings page title, to be displayed in menu and page headline
private static $plugin_title = "Simple Backup";
//page name
private static $plugin_name = "simple-backup";
//will be used as option name to save all options
private $setting_name = "simple-backup-settings";
//holds plugin options
private $opt = array();
//initialize the plugin class
public function __construct() {
$this->opt = get_option($this->setting_name);
//check pluign settings and display alert to configure and save plugin settings
add_action( 'admin_init', array(&$this, 'check_plugin_settings') );
//initialize plugin settings
add_action( 'admin_init', array(&$this, 'settings_page_init') );
//create menu in wp admin menu
add_action( 'admin_menu', array(&$this, 'admin_menu') );
//add help menu to settings page
//add_filter( 'contextual_help', array(&$this,'admin_help'), 10, 3);
// add plugin "Settings" action on plugin list
add_action('plugin_action_links_' . plugin_basename(SB_LOADER), array(&$this, 'add_plugin_actions'));
// add links for plugin help, donations,...
add_filter('plugin_row_meta', array(&$this, 'add_plugin_links'), 10, 2);
$backup_manager = new Simple_Backup_Manager($this->opt);
$this->backup_manager = $backup_manager;
add_action( 'admin_head', array($backup_manager, 'screen_options') );
add_action( 'admin_menu', array($backup_manager, 'simple_backup_admin_menu') );
if(isset($this->opt['backup_settings']['enable_ftp_backup_system']) && "true" == $this->opt['backup_settings']['enable_ftp_backup_system']){
$this->ftp_tools = new Simple_Backup_FTP_Tools();
}
}
//setup the plugin settings page
public function settings_page_init() {
$this->settings_page = new Simple_Backup_Settings_Page( $this->setting_name );
$this->settings_page->extra_tabs = array(array('id'=>'backup', 'title'=>'Backup Manager', 'link' => admin_url()."tools.php?page=backup_manager"));
//set the settings
$this->settings_page->set_sections( $this->get_settings_sections() );
$this->settings_page->set_fields( $this->get_settings_fields() );
$this->settings_page->set_sidebar( $this->get_settings_sidebar() );
$this->build_optional_tabs();
//initialize settings
$this->settings_page->init();
}
public function check_plugin_settings(){
if( isset($_GET['page']) ){
if ($_GET['page'] == "backup_manager" || $_GET['page'] == "simple-backup-settings" ){
//check for plugin settings, make sure they are saved
if(false === get_option($this->setting_name)){
$link = admin_url()."options-general.php?page=simple-backup-settings&tab=backup_settings";
$message = '<div class="error"><p>Welcome!<br>This plugin needs to be configured before you can make a backup.';
$message .= '<br>Please Configure and Save the <a href="%1$s">Plugin Settings</a> before you continue!!</p></div>';
echo sprintf($message, $link);
}
global $wp_version;
$req_wp_version = "3.3";
//check for proper WP version.
if (version_compare($wp_version, $req_wp_version, '<')) {
$message = '<div class="error"><p>Warning!<br>This plugin requires WordPress version '.$req_wp_version.' or later.';
$message .= '<br>Please <a href="'.admin_url().'update-core.php">Update WordPress</a> before you continue!</p></div>';
echo $message;
}
}
}
}
/**
* Returns all of the settings sections
*
* @return array settings sections
*/
public function get_settings_sections() {
$settings_sections = array(
array(
'id' => 'backup_settings',
'title' => __( 'Backup Settings', self::$plugin_name )
),
array(
'id' => 'wp_optimizer_settings',
'title' => __( 'WP Optimization', self::$plugin_name )
),
array(
'id' => 'db_optimizer_settings',
'title' => __( 'DB Optimization', self::$plugin_name )
)
);
if(isset($this->opt['backup_settings']['enable_ftp_backup_system']) && "true" == $this->opt['backup_settings']['enable_ftp_backup_system']){
$settings_sections[] = array(
'id' => 'ftp_server_settings',
'title' => __( 'FTP Settings', self::$plugin_name )
);
}
return $settings_sections;
}
/**
* Returns all of the settings fields
*
* @return array settings fields
*/
public function get_settings_fields() {
$settings_fields = array(
'backup_settings' => array(
array(
'name' => 'enable_file_backup',
'label' => __( 'File Backup', self::$plugin_name ),
'desc' => 'Enable WordPress File Backup',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'file_compression',
'label' => __( 'File Backup Format', self::$plugin_name ),
'desc' => 'Files Backup Format and Compression',
'type' => 'select',
//'default' => '.tar.gz',
'options' => array(
'.tar' => '.tar',
'.tar.gz' => '.tar.gz',
'.tar.bz2' => '.tar.bz2',
'.zip' => '.zip',
)
),
array(
'name' => 'enable_db_backup',
'label' => __( 'Database Backup', self::$plugin_name ),
'desc' => 'Enable WordPress Database Backup',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'db_compression',
'label' => __( 'Database Backup Format', self::$plugin_name ),
'desc' => 'Database Backup Format and Compression',
'type' => 'select',
//'default' => '.sql',
'options' => array(
'.sql' => '.sql',
'.sql.zip' => '.sql.zip',
'.sql.gz' => '.sql.gz',
'.sql.bz2' => '.sql.bz2',
)
),
array(
'name' => 'enable_ftp_backup_system',
'label' => __( 'FTP Storage', self::$plugin_name ),
'desc' => 'Enable FTP Storage for Backup Files.<br>(This is only necessary if you have a seperate FTP Server you need to copy your files to.)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'enable_htaccess_auto_security',
'label' => __( '.htaccess Security', self::$plugin_name ),
'desc' => 'Enable Automatic .htaccess Security for the Backup Directory.<br>(You can disable this option and manually create the .htaccess file, see the readme.txt for more information.)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
)
),
'wp_optimizer_settings' => array(
array(
'name' => 'delete_spam_comments',
'label' => __( 'Delete Spam Comments', self::$plugin_name ),
'desc' => 'Delete Spam Comments Before Backup (Recommended)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'delete_unapproved_comments',
'label' => __( 'Delete Un-Approved Comments', self::$plugin_name ),
'desc' => 'Delete Un-Approved Comments Before Backup (Advanced)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'delete_revisions',
'label' => __( 'Delete Revisions', self::$plugin_name ),
'desc' => 'Delete Revisions Before Backup (Advanced)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'delete_auto_drafts',
'label' => __( 'Delete Auto Drafts', self::$plugin_name ),
'desc' => 'Delete Auto Drafts Before Backup (Advanced)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'delete_transient_options',
'label' => __( 'Delete Transient Options', self::$plugin_name ),
'desc' => 'Delete Transient Options Before Backup (Advanced)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
)
),
'db_optimizer_settings' => array(
array(
'name' => 'optimize_database',
'label' => __( 'Optimize Database', self::$plugin_name ),
'desc' => 'Optimize WordPress MySQL Database Before Backup (Recommended)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'check_database',
'label' => __( 'Check Database', self::$plugin_name ),
'desc' => 'Check WordPress MySQL Database Before Backup (Recommended)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
),
array(
'name' => 'repair_database',
'label' => __( 'Repair Database', self::$plugin_name ),
'desc' => 'Repair WordPress MySQL Database Before Backup (Advanced)',
'type' => 'radio',
//'default' => 'true',
'options' => array(
'true' => 'Enabled',
'false' => 'Disabled'
)
)
),
'ftp_server_settings' => array(
array(
'name' => 'ftp_server_hostname',
'label' => __( 'Server Name', self::$plugin_name ),
'desc' => 'FTP Server Name or IP Address',
'type' => 'text'
),
array(
'name' => 'ftp_server_port',
'label' => __( 'Server Port', self::$plugin_name ),
'desc' => 'FTP Server Port Number',
'type' => 'text',
'default' => '21'
),
array(
'name' => 'ftp_server_username',
'label' => __( 'Server Username', self::$plugin_name ),
'desc' => 'FTP Server Username',
'type' => 'text'
),
array(
'name' => 'ftp_server_password',
'label' => __( 'Server Password', self::$plugin_name ),
'desc' => 'FTP Server Password',
'type' => 'text'
),
array(
'name' => 'ftp_server_directory',
'label' => __( 'Server Directory', self::$plugin_name ),
'desc' => 'Directory to Store Backups on FTP Server',
'type' => 'text',
'default' => 'simple-backup'
)
)
);
return $settings_fields;
}
//plugin settings page template
public function plugin_settings_page(){
echo "<style>
.form-table{ clear:left; }
.nav-tab-wrapper{ margin-bottom:0px; }
</style>";
echo $this->display_social_media();
echo '<div class="wrap" >';
echo '<div id="icon-'.$this->page_icon.'" class="icon32"><br /></div>';
echo "<h2>".self::$plugin_title." Plugin Settings</h2>";
//$this->show_backup_manager_link();
$this->show_do_backup_button();
$this->settings_page->show_tab_nav();
echo '<div id="poststuff" class="metabox-holder has-right-sidebar">';
echo '<div class="inner-sidebar">';
echo '<div id="side-sortables" class="meta-box-sortabless ui-sortable" style="position:relative;">';
$this->settings_page->show_sidebar();
echo '</div>';
echo '</div>';
echo '<div class="has-sidebar" >';
echo '<div id="post-body-content" class="has-sidebar-content">';
$this->settings_page->show_settings_forms();
//$this->show_do_backup_button();
$this->show_ftp_tools();
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
private function show_ftp_tools(){
if(isset($_GET['tab']) && ($_GET['tab'] == 'ftp_server_settings')){
echo "<form method='post' style='display:inline;'>";
echo '<div style=" margin-left:10px; margin-top:-10px;">';
echo "<input type='hidden' name='test-ftp-server' value='test-ftp-server'>";
echo "<input type='submit' class='button-secondary' value='Test FTP Settings'>";
echo "</div>";
echo "</form>";
}
if( isset($_GET['tab']) && ($_GET['tab'] == 'ftp_server_settings') && isset($_POST['test-ftp-server']) && ($_POST['test-ftp-server'] == "test-ftp-server") ){
$this->ftp_tools->connection_test();
}
}
/**
function ftp_recursive_file_listing($ftp_connection, $path = ".") {
static $allFiles = array();
$contents = ftp_nlist($ftp_connection, $path);
foreach($contents as $currentFile) {
// assuming its a folder if there's no dot in the name
if (strpos($currentFile, '.') === false) {
$this->ftp_recursive_file_listing($ftp_connection, $currentFile);
}
//$allFiles[$path][] = substr($currentFile, strlen($path) + 1);
$allFiles[$path][] = $currentFile;
}
return $allFiles;
}
**/
private function show_do_backup_button(){
//if(!isset($_GET['tab']) || ($_GET['tab'] != 'ftp_server_settings')){
echo "<form method='post' action='".admin_url()."tools.php?page=backup_manager' style='display:inline;'>";
echo '<div style=" margin-left:10px; margin-top:10px;">';
echo "<input type='hidden' name='simple-backup' value='simple-backup'>";
echo "<input type='submit' class='button-primary' value='Create WordPress Backup'>";
echo "</div>";
echo "</form>";
//}
}
private function show_backup_manager_link(){
echo "<p float='left'><a href='".get_option('siteurl')."/wp-admin/tools.php?page=backup_manager' >View Backup Manager</a></p>";
}
public function admin_menu() {
$this->page_menu = add_options_page( self::$plugin_title, self::$plugin_title, 'manage_options', $this->setting_name, array($this, 'plugin_settings_page') );
global $wp_version;
if($this->page_menu && version_compare($wp_version, '3.3', '>=')){
add_action("load-". $this->page_menu, array($this, 'admin_help'));
}
}
//public function admin_help($contextual_help, $screen_id, $screen){
public function admin_help(){
$screen = get_current_screen();
//global $simple_backup_file_manager_page;
//if ( $screen_id == $this->page_menu || $screen_id == $simple_backup_file_manager_page ) {
//if ( $screen == $this->page_menu ) {
//$support_the_dev = $this->display_support_us();
$support_the_dev =self::display_support_us();
$screen->add_help_tab(array(
'id' => 'developer-support',
'title' => "Support the Developer",
'content' => "<h2>Support the Developer</h2><p>".$support_the_dev."</p>"
));
$video_code = "<style>
.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>";
$video_code .= '<div class="videoWrapper"><iframe width="640" height="360" src="http://www.youtube.com/embed/W2YoEneu8H0?rel=0&vq=hd720" frameborder="0" allowfullscreen></iframe></div>';
$screen->add_help_tab(array(
'id' => 'tutorial-video',
'title' => "Tutorial Video",
'content' => "<h2>".self::$plugin_title." Tutorial Video</h2><p>$video_code</p>"
));
$screen->add_help_tab(array(
'id' => 'plugin-support',
'title' => "Plugin Support",
'content' => "<h2>".self::$plugin_title." Support</h2><p>For ".self::$plugin_title." Plugin Support please visit <a href='http://mywebsiteadvisor.com/support/' target='_blank'>MyWebsiteAdvisor.com</a></p>"
));
$plugin_faqs = "<p>For ".self::$plugin_title." Plugin Support please visit <a href='http://mywebsiteadvisor.com/support/' target='_blank'>MyWebsiteAdvisor.com</a></p>";
$plugin_faqs .= "<p><b>How can I setup Automatic Weekly or Monthly Backups?</b><br>
We offer a premium version of the plugin which includes advanced features such as Automatic Scheduled Backups!<br>
<b><a href='http://mywebsiteadvisor.com/plugins/simple-backup/' target='_blank'>Learn More about Simple Backup Ultra</a></b></p>";
$plugin_faqs .= "<p><b>FTP Server Settings</b><br>The FTP options are a common point of confusion for many people. <br>
The FTP System is Optional and only necessary if you have an FTP server which is seperate from your website. <br>
Some Web Hosting providers provide an FTP Backup server, or you could setup an FTP on your Home Computer and setup the plugin to transfer the backup files to that FTP Server.</p>";
$plugin_faqs .= "<p><b>Restoring Backups</b><br>This plugin does not contain any features to restore the backup files which it creates.<br>
Most likely if you should need to restore backups you will not have access to your website or the plugin.<br>
For that reason the plugin creates the backup files in standard, commonly used formats.<br>
<br>
<b>More information on how to restore backup files can be found here:</b><br>
<a href='http://mywebsiteadvisor.com/learning/software-tutorials/restoring-wordpress-backups/' target='_blank'>Restoring WordPress Backups Tutorial</a></p>";
$screen->add_help_tab(array(
'id' => 'plugin-faqs',
'title' => "Plugin FAQs",
'content' => "<h2>".self::$plugin_title." Frequently Asked Questions</h2>$plugin_faqs"
));
$screen->add_help_tab(array(
'id' => 'upgrade_plugin',
'title' => __( 'Plugin Upgrades', self::$plugin_name ),
'content' => self::get_plugin_upgrades()
));
$disable_plugin_installer_nonce = wp_create_nonce("mywebsiteadvisor-plugin-installer-menu-disable");
$plugin_installer_ajax = " <script>
function update_mwa_display_plugin_installer_options(){
jQuery('#display_mwa_plugin_installer_label').text('Updating...');
var option_checked = jQuery('#display_mywebsiteadvisor_plugin_installer_menu:checked').length > 0;
var ajax_data = {
'checked': option_checked,
'action': 'update_mwa_plugin_installer_menu_option',
'security': '$disable_plugin_installer_nonce'
};
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: ajax_data,
success: function(data){
if(data == 'true'){
jQuery('#display_mwa_plugin_installer_label').text(' MyWebsiteAdvisor Plugin Installer Menu Enabled!');
}
if(data == 'false'){
jQuery('#display_mwa_plugin_installer_label').text(' MyWebsiteAdvisor Plugin Installer Menu Disabled!');
}
//alert(data);
//location.reload();
}
});
}</script>";
$checked = "";
$enabled = get_option('mywebsiteadvisor_pluigin_installer_menu_disable');
if(!isset($enabled) || $enabled == 'true'){
$checked = "checked='checked'";
$content = "<h2>More Free Plugins from MyWebsiteAdvisor.com</h2><p>Install More Free Plugins from MyWebsiteAdvisor.com <a href='".admin_url()."plugins.php?page=MyWebsiteAdvisor' target='_blank'>Click here</a></p>";
}else{
$checked = "";
$content = "<h2>More Free Plugins from MyWebsiteAdvisor.com</h2><p>Install More Free Plugins from MyWebsiteAdvisor.com <a href='".admin_url()."plugin-install.php?tab=search&type=author&s=MyWebsiteAdvisor' target='_blank'>Click here</a></p>";
}
$content .= $plugin_installer_ajax . "
<p><input type='checkbox' $checked id='display_mywebsiteadvisor_plugin_installer_menu' name='display_mywebsiteadvisor_plugin_installer_menu' onclick='update_mwa_display_plugin_installer_options()' /> <label id='display_mwa_plugin_installer_label' for='display_mywebsiteadvisor_plugin_installer_menu' > Check here to display the MyWebsiteAdvisor Plugin Installer page in the Plugins menu.</label></p>";
$screen->add_help_tab(array(
'id' => 'more-free-plugins',
'title' => "More Free Plugins",
'content' => $content
));
$help_sidebar = "<p>Please Visit us online for more Free WordPress Plugins!</p>";
$help_sidebar .= "<p><a href='http://mywebsiteadvisor.com/plugins/' target='_blank'>MyWebsiteAdvisor.com</a></p>";
$help_sidebar .= "<br>";
$help_sidebar .= "<p>Install more FREE WordPress Plugins from MyWebsiteAdvisor.com </p>";
$enabled = get_option('mywebsiteadvisor_pluigin_installer_menu_disable');
if(!isset($enabled) || $enabled == 'true'){
$help_sidebar .= "<p><a href='".admin_url()."plugins.php?page=MyWebsiteAdvisor' target='_blank'>Click here</a></p>";
}else{
$help_sidebar .= "<p><a href='".admin_url()."plugin-install.php?tab=search&type=author&s=MyWebsiteAdvisor' target='_blank'>Click here</a></p>";
}
$screen->set_help_sidebar($help_sidebar);
// }
}
private function do_diagnostic_sidebar(){
ob_start();
echo "<p>Plugin Version: $this->version</p>";
echo "<p>Server OS: ".PHP_OS." (" . strlen(decbin(~0)) . " bit)</p>";
echo "<p>Required PHP Version: 5.2+<br>";
echo "Current PHP Version: " . phpversion() . "</p>";
if( ini_get('safe_mode') ){
echo "<p><font color='red'>PHP Safe Mode is enabled!<br><b>Disable Safe Mode in php.ini!</b></font></p>";
}else{
echo "<p>PHP Safe Mode: is disabled!</p>";
}
if(strpos(ini_get('disable_functions'), 'exec') !== false){
echo "<p><font color='red'>Disabled Functions: ".ini_get('disable_functions')."<br><b>Please enable 'exec' function in php.ini!</b></font></p>";
}
if( strpos(ini_get('disable_functions'), 'passthru') !== false){
echo "<p><font color='red'>Disabled Functions: ".ini_get('disable_functions')."<br><b>Please enable 'passthru' function in php.ini!</b></font></p>";
}
if(function_exists('exec')){
echo "<p>";
if(exec('type tar')){
echo "Command 'tar' is enabled!</br>";
}else{
echo "Command 'tar' was not found!</br>";
}
if(exec('type gzip')){
echo "Command 'gzip' is enabled!</br>";
}else{
echo "Command 'gzip' was not found!</br>";
}
if(exec('type bzip2')){
echo "Command 'bzip2' is enabled!</br>";
}else{
echo "Command 'bzip2' was not found!</br>";
}
if(exec('type zip')){
echo "Command 'zip' is enabled!</br>";
}else{
echo "Command 'zip' was not found!</br>";
}
if(exec('type mysqldump')){
echo "Command 'mysqldump' is enabled!</br>";
}else{
echo "Command 'mysqldump' was not found!</br>";
}
echo "</p>";
}
echo "<p>Memory Use: " . number_format(memory_get_usage()/1024/1024, 1) . " / " . ini_get('memory_limit') . "</p>";
echo "<p>Peak Memory Use: " . number_format(memory_get_peak_usage()/1024/1024, 1) . " / " . ini_get('memory_limit') . "</p>";
if(function_exists('sys_getloadavg')){
$lav = sys_getloadavg();
echo "<p>Server Load Average: ".$lav[0].", ".$lav[1].", ".$lav[2]."</p>";
}
$bytes =@disk_free_space(".");
echo "<p>Disk Space Available: " . size_format( $bytes, 2 ) . " (Approx.)</p>";
if(function_exists('exec')){
$bytes = exec("du -s " . ABSPATH . " --exclude '".ABSPATH."simple-backup/*'");
$size = explode(" ", $bytes);
echo "<p>WordPress File Size: " . size_format(($size[0] * 1024)) . " (Approx.)</p>";
}
global $wpdb;
$status_rows = $wpdb->get_results( "SHOW TABLE STATUS" );
$size = 0;
foreach($status_rows as $row){
$size += $row->Data_length;
}
echo "<p>WordPress DB Size: " . size_format($size) . " (Approx.)</p>";
return ob_get_clean();
}
private function get_settings_sidebar(){
$plugin_resources = "<p><a href='http://mywebsiteadvisor.com/plugins/simple-backup/' target='_blank'>Plugin Homepage</a></p>
<p><a href='http://mywebsiteadvisor.com/learning/video-tutorials/simple-backup-tutorial/' target='_blank'>Plugin Tutorial</a></p>
<p><a href='http://mywebsiteadvisor.com/support/' target='_blank'>Plugin Support</a></p>
<p><a href='http://mywebsiteadvisor.com/contact-us/' target='_blank'>Contact Us</a></p>
<p><b><a href='http://wordpress.org/support/view/plugin-reviews/simple-backup?rate=5#postform' target='_blank'>Rate and Review This Plugin</a></b></p>";
$enabled = get_option('mywebsiteadvisor_pluigin_installer_menu_disable');
if(!isset($enabled) || $enabled == 'true'){
$more_plugins = "<p><b><a href='".admin_url()."plugins.php?page=MyWebsiteAdvisor' target='_blank' title='Install More Free Plugins from MyWebsiteAdvisor.com!'>Install More Free Plugins!</a></b></p>";
}else{
$more_plugins = "<p><b><a href='".admin_url()."plugin-install.php?tab=search&type=author&s=MyWebsiteAdvisor' target='_blank' title='Install More Free Plugins from MyWebsiteAdvisor.com!'>Install More Free Plugins!</a></b></p>";
}
$more_plugins .= "<p><a href='http://mywebsiteadvisor.com/plugins/' target='_blank'>Premium WordPress Plugins!</a></p>
<p><a href='http://profiles.wordpress.org/MyWebsiteAdvisor/' target='_blank'>Free Plugins on Wordpress.org!</a></p>
<p><a href='http://mywebsiteadvisor.com/plugins/' target='_blank'>Free Plugins on MyWebsiteAdvisor.com!</a></p>";
$follow_us = "<p><a href='http://facebook.com/MyWebsiteAdvisor/' target='_blank'>Follow us on Facebook!</a></p>
<p><a href='http://twitter.com/MWebsiteAdvisor/' target='_blank'>Follow us on Twitter!</a></p>
<p><a href='http://www.youtube.com/mywebsiteadvisor' target='_blank'>Watch us on YouTube!</a></p>
<p><a href='http://MyWebsiteAdvisor.com/' target='_blank'>Visit our Website!</a></p>";
$upgrade = "<p>
<b><a href='http://mywebsiteadvisor.com/plugins/simple-backup/' target='_blank'>Upgrade to Simple Backup Ultra!</a></b><br />
<br />
<b>Features:</b><br />
-Automatic Backup Function<br />
-Email Backup Notification<br />
-Daily, Weekly or Monthly Schedule<br />
-Much More!</br>
</p>";
$sidebar_info = array(
array(
'id' => 'diagnostic',
'title' => 'Plugin Diagnostic Check',
'content' => $this->do_diagnostic_sidebar()
),
array(
'id' => 'resources',
'title' => 'Plugin Resources',
'content' => $plugin_resources
),
array(
'id' => 'upgrade',
'title' => 'Plugin Upgrades',
'content' => $upgrade
),
array(
'id' => 'more_plugins',
'title' => 'More Plugins',
'content' => $more_plugins
),
array(
'id' => 'follow_us',
'title' => 'Follow MyWebsiteAdvisor',
'content' => $follow_us
)
);
return $sidebar_info;
}
//build optional tabs, using debug tools class worker methods as callbacks
private function build_optional_tabs(){
if(true === $this->debug){
//general debug settings
$plugin_debug = array(
'id' => 'plugin_debug',
'title' => __( 'Plugin Settings Debug', self::$plugin_name ),
'callback' => array(&$this, 'show_plugin_settings')
);
//$enabled = isset($this->opt['debug_settings']['enable_display_plugin_settings']) ? $this->opt['debug_settings']['enable_display_plugin_settings'] : 'false';
//if( $enabled === 'true' ){
$this->settings_page->add_section( $plugin_debug );
//}
}
$plugin_tutorial = array(
'id' => 'plugin_tutorial',
'title' => __( 'Plugin Tutorial Video', self::$plugin_name ),
'callback' => array(&$this, 'show_plugin_tutorual')
);
$this->settings_page->add_section( $plugin_tutorial );
$upgrade_plugin = array(
'id' => 'upgrade_plugin',
'title' => __( 'Plugin Upgrades', self::$plugin_name ),
'callback' => array(&$this, 'show_plugin_upgrades')
);
$this->settings_page->add_section( $upgrade_plugin );
}
public function get_plugin_upgrades(){
ob_start();
self::show_plugin_upgrades();
return ob_get_clean();
}
public function show_plugin_upgrades(){
$html = "<style>
ul.upgrade_features li { list-style-type: disc; }
ul.upgrade_features { margin-left:30px;}
</style>";
$html .= "<script>
function simple_backup_upgrade(){
window.open('http://mywebsiteadvisor.com/plugins/simple-backup/');
return false;
}
function try_simple_optimizer(){
window.open('http://wordpress.org/extend/plugins/simple-optimizer/');
return false;
}
function try_simple_security(){
window.open('http://wordpress.org/extend/plugins/simple-security/');
return false;
}
function simple_backup_learn_more(){
window.open('http://mywebsiteadvisor.com/plugins/simple-backup/');
return false;
}
function simple_optimizer_learn_more(){
window.open('http://mywebsiteadvisor.com/plugins/simple-optimizer/');
return false;
}
function simple_security_learn_more(){
window.open('http://mywebsiteadvisor.com/plugins/simple-security/');
return false;
}
</script>";
$html .= "</form><h2>Upgrade to Simple Backup Ultra Today!</h2>";
$html .= "<p><b>Premium Features include:</b></p>";
$html .= "<ul class='upgrade_features'>";
$html .= "<li>Schedule Automatic WordPress Backups</li>";
$html .= "<li>Scheduled Automatic WordPress and Database Optimizations</li>";
$html .= "<li>Recieve email notification of the scheduled backup status</li>";
$html .= "<li>Priority Support License</li>";
$html .= "</ul>";
$html .= '<div style="padding-left: 1.5em; margin-left:5px;">';
$html .= "<p class='submit'>";
$html .= "<input type='submit' class='button-primary' value='Upgrade to Simple Backup Ultra »' onclick='return simple_backup_upgrade()'> ";
$html .= "<input type='submit' class='button-secondary' value='Learn More »' onclick='return simple_backup_learn_more()'>";
$html .= "</p>";
$html .= "</div>";
$html .= "<hr>";
$html .= "<h2>Also Try Simple Optimizer!</h2>";
$html .= "<p>Simple Optimizer can help keep your website running quickly and smoothly by cleaning up the WordPress Database of un-used and un-necessary information.</p>";
$html .= '<div style="padding-left: 1.5em; margin-left:5px;">';
$html .= "<p class='submit'>";
$html .= "<input type='submit' class='button-primary' value='Try Simple Optimizer »' onclick='return try_simple_optimizer()'> ";
$html .= "<input type='submit' class='button-secondary' value='Learn More »' onclick='return simple_optimizer_learn_more()'>";
$html .= "</p>";
$html .= "</div>";
$html .= "<hr>";
$html .= "<h2>Also Try Simple Security!</h2>";
$html .= "<p>Simple Security is an access log system for WordPress which can automatically block access to your website after a specified number of failed login attempts from an IP Address.</p>";
$html .= '<div style="padding-left: 1.5em; margin-left:5px;">';
$html .= "<p class='submit'>";
$html .= "<input type='submit' class='button-primary' value='Try Simple Security »' onclick='return try_simple_security()'> ";
$html .= "<input type='submit' class='button-secondary' value='Learn More »' onclick='return simple_security_learn_more()'>";
$html .= "</p>";
$html .= "</div>";
echo $html;
}