1 | <?php
|
---|
2 |
|
---|
3 | load_plugin_textdomain('xpressme', 'wp-content/plugins/xpressme/language');
|
---|
4 |
|
---|
5 | class XPressME_Class{
|
---|
6 | var $pluginName = 'xpressme';
|
---|
7 | var $is_use_xoops_upload_path;
|
---|
8 |
|
---|
9 | //constructor
|
---|
10 | function XPressME_Class()
|
---|
11 | {
|
---|
12 | $this->setdefault(); //not setting propaty load
|
---|
13 | $this->SettingValueRead();
|
---|
14 | }
|
---|
15 |
|
---|
16 |
|
---|
17 | function add_option_page()
|
---|
18 | {
|
---|
19 | add_options_page('XPressME', __('XPressME Settings', 'xpressme'), 8, 'xpressme_config', array(&$this, 'option_page'));
|
---|
20 | }
|
---|
21 |
|
---|
22 | function add_admin_head()
|
---|
23 | {
|
---|
24 | // add header text
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | //Set Default Value
|
---|
29 | function setDefault()
|
---|
30 | {
|
---|
31 | $this->is_use_xoops_upload_path = true;
|
---|
32 | }
|
---|
33 |
|
---|
34 | function SettingValueRead()
|
---|
35 | {
|
---|
36 | $options = get_option('xpressme_option');
|
---|
37 | if (!$options) {
|
---|
38 | $this->setDefault();
|
---|
39 | $this->SettingValueWrite('add_new');
|
---|
40 | } else {
|
---|
41 | foreach ($options as $option_name => $option_value){
|
---|
42 | $this-> {$option_name} = $option_value;
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | // mode 0:add 1:update
|
---|
48 | function SettingValueWrite($mode)
|
---|
49 | {
|
---|
50 | $write_options = array (
|
---|
51 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path
|
---|
52 | );
|
---|
53 | if ($mode == 'add_new') {
|
---|
54 | add_option('xpressme_option', $write_options);
|
---|
55 | } else {
|
---|
56 | update_option("xpressme_option", $write_options);
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | function ReadPostData()
|
---|
61 | {
|
---|
62 | $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
|
---|
63 | }
|
---|
64 |
|
---|
65 | function option_page()
|
---|
66 | {
|
---|
67 | if (!empty($_POST['submit_update'])) {
|
---|
68 | $this->ReadPostData();
|
---|
69 | $this->SettingValueWrite('update');
|
---|
70 | } else if (isset($_POST['submit_reset'])) {
|
---|
71 | $this->fck_setDefault();
|
---|
72 | $this->SettingValueWrite('update');
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | echo '<div class="wrap">';
|
---|
77 | echo '<div id="icon-options-general" class="icon32"><br /></div>';
|
---|
78 | echo '<h2>' . __('XPressME Configuration Page', 'xpressme') . '</h2> ';
|
---|
79 |
|
---|
80 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">' ;
|
---|
81 | echo '<table class="form-table">';
|
---|
82 | $this->is_use_xoops_upload_path_html();
|
---|
83 | echo '</table>';
|
---|
84 |
|
---|
85 | echo '<p class="submit">';
|
---|
86 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />';
|
---|
87 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />';
|
---|
88 | echo '</p>';
|
---|
89 |
|
---|
90 | echo '</form>' ;
|
---|
91 | echo '</div>';
|
---|
92 | }
|
---|
93 |
|
---|
94 | function is_use_xoops_upload_path_html()
|
---|
95 | {
|
---|
96 |
|
---|
97 | echo '<tr>';
|
---|
98 | echo '<th><label for="images_to_link">' . __('Media Upload Base Path','xpressme') . '</label></th>';
|
---|
99 | echo '<td>';
|
---|
100 |
|
---|
101 | if ($this->is_use_xoops_upload_path == true){
|
---|
102 | echo '<label><input type="radio" name="ch_is_use_xoops_upload_path" value="1" checked="checked" /> ' . __('Use XOOPS UPLOAD PATH','xpressme') .'</label><br />';
|
---|
103 | echo '<label><input type="radio" name="ch_is_use_xoops_upload_path" value="0" />' . __('USE WordPress BASE_PATH','xpressme') . '</label>';
|
---|
104 | } else {
|
---|
105 | echo '<label><input type="radio" name="ch_is_use_xoops_upload_path" value="1" /> ' . __('Use XOOPS UPLOAD PATH','xpressme') .'</label><br />';
|
---|
106 | echo '<label><input type="radio" name="ch_is_use_xoops_upload_path" value="0" checked="checked" />' . __('USE WordPress BASE_PATH','xpressme') . '</label>';
|
---|
107 | }
|
---|
108 | echo '</td>';
|
---|
109 | echo '</tr><tr>';
|
---|
110 |
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | function xpress_upload_filter($uploads)
|
---|
115 | {
|
---|
116 | if ($this->is_use_xoops_upload_path){
|
---|
117 | if (!defined("XOOPS_UPLOAD_PATH"))
|
---|
118 | define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH."/uploads");
|
---|
119 | if (!defined("XOOPS_UPLOAD_URL"))
|
---|
120 | define("XOOPS_UPLOAD_URL", XOOPS_URL."/uploads");
|
---|
121 |
|
---|
122 | $wordpress_dir = ABSPATH ;
|
---|
123 | $xoops_dir = XOOPS_UPLOAD_PATH . '/';
|
---|
124 | $wordpress_base_url = get_option( 'siteurl' );
|
---|
125 | $xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
126 |
|
---|
127 | $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
|
---|
128 | $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
|
---|
129 | $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
|
---|
130 | $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
|
---|
131 | }
|
---|
132 | return $uploads;
|
---|
133 | }
|
---|
134 | }
|
---|
135 | ?> |
---|