PluginProbe
FeedWordPress / 2020.0118
FeedWordPress v2020.0118
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | feedwordpresssettingsui.class.php +35 -117 trunk2020.0118 View file →
@@ -3,90 +3,65 @@
3 3 * class FeedWordPressSettingsUI: Module to package several functions related to the
4 4 * WordPress administrative / settings interface.
5 5 */
6 6 class FeedWordPressSettingsUI {
7 - /**
8 - * Checks if current user is an administrator with permissions to
9 - * see the FWP dashboard.
10 - *
11 - * @return bool True if current user is an administrator.
12 - *
13 - * @uses is_admin()
14 - * @uses FeedWordPress::path()
15 - * @uses MyPHP::request()
16 - */
17 - static function is_admin() {
7 + static function is_admin () {
8 + global $fwp_path;
9 +
18 10 $admin_page = false; // Innocent until proven guilty
19 - if ( ! is_null( MyPHP::request( 'page' ) ) ) :
20 - $fwp = preg_quote( FeedWordPress::path() );
11 + if (isset($_REQUEST['page'])) :
21 12 $admin_page = (
22 13 is_admin()
23 - and preg_match( "|^{$fwp}/|", MyPHP::request( 'page' ) )
14 + and preg_match("|^{$fwp_path}/|", $_REQUEST['page'])
24 15 );
25 16 endif;
26 17 return $admin_page;
27 18 }
28 19
29 - /**
30 - * Enqueues JavaScript for the administration dashboard.
31 - */
32 - static function admin_scripts() {
33 - wp_enqueue_script( 'post' ); // for magic tag and category boxes
34 - wp_enqueue_script( 'admin-forms' ); // for checkbox selection
20 + static function admin_scripts () {
21 + global $fwp_path;
35 22
36 - wp_register_script( 'feedwordpress-elements', plugins_url( 'assets/js/feedwordpress-elements.js', __FILE__ ) );
37 - wp_enqueue_script( 'feedwordpress-elements' );
23 + wp_enqueue_script('post'); // for magic tag and category boxes
24 + wp_enqueue_script('admin-forms'); // for checkbox selection
25 +
26 + wp_register_script('feedwordpress-elements', plugins_url('/' . $fwp_path . '/feedwordpress-elements.js') );
27 + wp_enqueue_script('feedwordpress-elements');
38 28 }
39 29
40 - /**
41 - * Sets the CSS for the administration dashboard.
42 - *
43 - * @todo At some point in the future, these ought to be changed to modern designs,
44 - * i.e. either Dashicons or the upcoming SVG icon fonts. (gwyneth 20210717)
45 - */
46 - static function admin_styles() {
30 + static function admin_styles () {
47 31 ?>
48 32 <style type="text/css">
49 33 #feedwordpress-admin-feeds .link-rss-params-remove .x, .feedwordpress-admin .remove-it .x {
50 - content: "\f153"; /* dashicons-dismiss */
51 - color: var(--wp-components-color-foreground,#1e1e1e);
52 - background-color: var(--wp-components-color-background);
34 + background: url(<?php print admin_url('images/xit.gif') ?>) no-repeat scroll 0 0 transparent;
53 35 }
36 +
54 37 #feedwordpress-admin-feeds .link-rss-params-remove:hover .x, .feedwordpress-admin .remove-it:hover .x {
55 - content: "\f153"; /* dashicons-dismiss */
56 - color: var(--wp-components-color-accent);
57 - background-color: var(--wp-components-color-background);
38 + background: url(<?php print admin_url('images/xit.gif') ?>) no-repeat scroll -10px 0 transparent;
58 39 }
59 40
60 - /* Note: the old images referred here were deprecated around 2009 or so and are *not*
61 - part of the WordPress core any more; see https://core.trac.wordpress.org/ticket/20980
62 - I have placed these missing images on the images folder instead (gwyneth 20210717) */
63 41 .fwpfs {
64 - background-image: url(<?php echo esc_url( plugins_url( 'assets/images/fav.png', __FILE__ ) ); ?>);
42 + background-image: url(<?php print admin_url('images/fav.png'); ?>);
65 43 background-repeat: repeat-x;
66 44 background-position: left center;
67 45 background-attachment: scroll;
68 46 }
69 47 .fwpfs.slide-down {
70 - background-image: url(<?php echo esc_url( plugins_url( 'assets/images/fav-top.png', __FILE__ ) ); ?>);
71 - background-position: 0 top;
72 - background-repeat: repeat-x;
48 + background-image:url(<?php print admin_url('images/fav-top.png'); ?>);
49 + background-position:0 top;
50 + background-repeat:repeat-x;
73 51 }
52 +
74 53 .update-results {
75 54 max-width: 100%;
76 55 overflow: auto;
77 56 }
57 +
78 58 </style>
79 59 <?php
80 60 } /* FeedWordPressSettingsUI::admin_styles () */
81 61
82 - /**
83 - * Makes sure we have nonce active.
84 - *
85 - * @uses wp_nonce_field()
86 - */
87 - static function ajax_nonce_fields() {
88 - if ( function_exists( 'wp_nonce_field' ) ) :
62 + static function ajax_nonce_fields () {
63 + if (function_exists('wp_nonce_field')) :
89 64 echo "<form style='display: none' method='get' action=''>\n<p>\n";
90 65 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
91 66 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
92 67 echo "</p>\n</form>\n";
@@ -103,88 +78,31 @@
103 78 $('.hide-postbox-tog').unbind('click');
104 79 $('.columns-prefs input[type="radio"]').unbind('click');
105 80 $('.meta-box-sortables').sortable('destroy');
106 81
107 - postboxes.add_postbox_toggles('<?php print esc_attr( $context ); ?>');
82 + postboxes.add_postbox_toggles('<?php print $context; ?>');
108 83 } );
109 84 </script>
110 85 <?php
111 86 } /* FeedWordPressSettingsUI::fix_toggles_js () */
112 87
113 - /**
114 - * get_template_part: load a template (usually templated HTML) from the FeedWordPress plugins
115 - * directory, in a way similar to the WordPress theme function get_template_part() loads a
116 - * template module from the theme directory.
117 - *
118 - * @param string $slug The slug name for the generic template
119 - * @param string $name The name of the specialized template
120 - * @param array $args Additional arguments passed to the template.
121 - */
122 - static public function get_template_part( $slug, $name = null, $type = null, $args = array() ) {
123 - global $feedwordpress;
124 -
125 - do_action( "feedwordpress_get_template_part_{$slug}", $slug, $name, $type, $args );
126 -
127 - $templates = array();
128 - $name = (string) $name;
129 - $type = (string) $type;
130 -
131 - $ext = ".php";
132 - if ( strlen( $type ) > 0 ):
133 - $ext = ".{$type}{$ext}";
134 - endif;
135 -
136 - if ( strlen( $name ) > 0 ) :
137 - $templates[] = "{$slug}-{$name}{$ext}";
138 - endif;
139 - $templates[] = "{$slug}{$ext}";
140 -
141 - do_action( "feedwordpress_get_template_part", $slug, $name, $type, $args );
142 -
143 - // locate_template
144 - $located = '';
145 - foreach ( $templates as $template_name ) :
146 - if ( !! $template_name ) :
147 - $templatePath = $feedwordpress->plugin_dir_path( 'templates/' . $template_name );
148 - if ( is_readable( $templatePath ) ) :
149 - $located = $templatePath;
150 - break;
151 - endif;
88 + static function magic_input_tip_js ($id) {
89 + if (!preg_match('/^[.#]/', $id)) :
90 + $id = '#'.$id;
152 91 endif;
153 - endforeach;
154 -
155 - if ( strlen( $located ) > 0 ) :
156 - load_template( $located, /*require_once=*/ false, /*args=*/ $args );
157 - endif;
158 - } /* FeedWordPressSettingsUI::get_template_part () */
159 -
160 - /**
161 - * Generates contextual hovering text with tips for the form fields.
162 - *
163 - * How exactly this works is beyond myself. (gwyneth 20230916)
164 - *
165 - * @param string $id Apparently it's the field's id attribute.
166 - *
167 - */
168 - static function magic_input_tip_js( $id ) {
169 - if ( ! preg_match( '/^[.#]/', $id ) ) :
170 - $id = '#' . $id;
171 - endif;
172 92 ?>
173 93 <script type="text/javascript">
174 - jQuery( document ).ready( function () {
175 - var inputBox = jQuery( "<?php print esc_attr( $id ); ?>" );
176 - var boxEl = inputBox.get( 0 );
177 - if ( boxEl.value == boxEl.defaultValue ) {
178 - inputBox.addClass( 'form-input-tip' );
179 - }
94 + jQuery(document).ready( function () {
95 + var inputBox = jQuery("<?php print $id; ?>");
96 + var boxEl = inputBox.get(0);
97 + if (boxEl.value==boxEl.defaultValue) { inputBox.addClass('form-input-tip'); }
180 98 inputBox.focus(function() {
181 99 if ( this.value == this.defaultValue )
182 - jQuery( this ).val( '' ).removeClass( 'form-input-tip' );
100 + jQuery(this).val( '' ).removeClass( 'form-input-tip' );
183 101 });
184 - inputBox.blur( function() {
102 + inputBox.blur(function() {
185 103 if ( this.value == '' )
186 - jQuery( this ).val( this.defaultValue ).addClass( 'form-input-tip' );
104 + jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
187 105 });
188 106 } );
189 107 </script>
190 108 <?php