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 wp_fckeditor()
|
---|
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 | // add_submenu_page('post.php', 'FCKEditor','FCKEditor',1, 'xpress_fckeditor', array(&$this, 'option_page'));
|
---|
21 | }
|
---|
22 |
|
---|
23 | function add_admin_head()
|
---|
24 | {
|
---|
25 | // add header text
|
---|
26 | }
|
---|
27 |
|
---|
28 |
|
---|
29 | //Set Default Value
|
---|
30 | function setDefault()
|
---|
31 | {
|
---|
32 | $this->is_use_xoops_upload_path = true;
|
---|
33 | }
|
---|
34 |
|
---|
35 | function SettingValueRead()
|
---|
36 | {
|
---|
37 | $options = get_option('xpressme_option');
|
---|
38 |
|
---|
39 | if (!$options) {
|
---|
40 | $this->setDefault();
|
---|
41 | $this->SettingValueWrite('add_new');
|
---|
42 | } else {
|
---|
43 | foreach ($options as $option_name => $option_value){
|
---|
44 | $this-> {$option_name} = $option_value;
|
---|
45 | }
|
---|
46 | $this->build_smiley_images($this->fck_SmileyPath,$this->fck_SmileyName);
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|
50 |
|
---|
51 | // mode 0:add 1:update
|
---|
52 | function SettingValueWrite($mode)
|
---|
53 | {
|
---|
54 | $write_options = array (
|
---|
55 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path
|
---|
56 | );
|
---|
57 | if ($mode == 'add_new') {
|
---|
58 | add_option('xpressme_option', $write_options);
|
---|
59 | } else {
|
---|
60 | update_option("xpressme_option", $write_options);
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | function option_page()
|
---|
65 | {
|
---|
66 | echo '<div class="wrap">';
|
---|
67 | echo '<div id="icon-options-general" class="icon32"><br /></div>';
|
---|
68 | echo '<h2>' . __('XPressME Configuration Page', 'xpressme') . '</h2> ';
|
---|
69 |
|
---|
70 | echo '<form method="post" action="options.php">';
|
---|
71 | echo '<table class="form-table">';
|
---|
72 |
|
---|
73 | $this->is_use_xoops_upload_path_html();
|
---|
74 | echo '</table>';
|
---|
75 | echo '</div>';
|
---|
76 |
|
---|
77 | }
|
---|
78 |
|
---|
79 | function is_use_xoops_upload_path_html()
|
---|
80 | {
|
---|
81 |
|
---|
82 | echo '<tr>';
|
---|
83 | echo '<th><label for="images_to_link">' . __('Media Upload Base Path','xpressme') . '</label></th>';
|
---|
84 | echo '<td>';
|
---|
85 |
|
---|
86 | // if ($this->is_use_xoops_upload_path == true){
|
---|
87 | echo '<label><input type="radio" name="ch_is_use_xoops_upload_path" value="1" checked="checked" /> ' . __('Use XOOPS UPLOAD PATH','xpressme') .'</label><br />';
|
---|
88 | echo '<label><input type="radio" name="ch_is_use_xoops_upload_path" value="0" />' . __('USE WordPress BASE_PATH','xpressme') . '</label>';
|
---|
89 | echo '</td>';
|
---|
90 | echo '</tr><tr>';
|
---|
91 |
|
---|
92 | }
|
---|
93 |
|
---|
94 |
|
---|
95 | function xpress_upload_filter($uploads)
|
---|
96 | {
|
---|
97 | if ($this->is_use_xoops_upload_path){
|
---|
98 | if (!defined("XOOPS_UPLOAD_PATH"))
|
---|
99 | define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH."/uploads");
|
---|
100 | if (!defined("XOOPS_UPLOAD_URL"))
|
---|
101 | define("XOOPS_UPLOAD_URL", XOOPS_URL."/uploads");
|
---|
102 |
|
---|
103 | $wordpress_dir = ABSPATH ;
|
---|
104 | $xoops_dir = XOOPS_UPLOAD_PATH . '/';
|
---|
105 | $wordpress_base_url = get_option( 'siteurl' );
|
---|
106 | $xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
107 |
|
---|
108 | $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
|
---|
109 | $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
|
---|
110 | $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
|
---|
111 | $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
|
---|
112 | }
|
---|
113 | return $uploads;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | ?> |
---|