Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Taxonomy Dropdown Widget
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
Taxonomy Dropdown Widget
Commits
f48b8bde
Commit
f48b8bde
authored
11 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Widget shouldn't rely on the old global, now that we're using a proper singleton.
parent
eb36f70e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tag-dropdown-widget.php
+15
-26
15 additions, 26 deletions
tag-dropdown-widget.php
with
15 additions
and
26 deletions
tag-dropdown-widget.php
+
15
−
26
View file @
f48b8bde
...
...
@@ -347,56 +347,51 @@ class taxonomy_dropdown_widget extends WP_Widget {
'title'
=>
'Tags'
,
);
private
$plugin
=
null
;
/**
* Register widget and populate class variables
* @uses this::WP_Widget
* @uses taxonomy_dropdown_widget_plugin
* @uses taxonomy_dropdown_widget_plugin
::get_instance
* @return null
*/
public
function
__construct
()
{
$this
->
WP_Widget
(
false
,
'Taxonomy Dropdown Widget'
,
array
(
'description'
=>
'Displays selected non-hierarchical taxonomy terms in a dropdown list.'
)
);
//Load plugin class and populate defaults
global
$taxonomy_dropdown_widget_plugin
;
if
(
!
is_a
(
$taxonomy_dropdown_widget_plugin
,
'taxonomy_dropdown_widget_plugin'
)
)
$taxonomy_dropdown_widget_plugin
=
new
taxonomy_dropdown_widget_plugin
;
// Shortcut to the main plugin instance from within the widget class
$this
->
plugin
=
taxonomy_dropdown_widget_plugin
::
get_instance
();
if
(
is_object
(
$taxonomy_dropdown_widget_plugin
)
&&
property_exists
(
$taxonomy_dropdown_widget_plugin
,
'option_defaults'
)
&&
is_array
(
$taxonomy_dropdown_widget_plugin
->
option_defaults
)
)
$this
->
defaults
=
array_merge
(
$taxonomy_dropdown_widget_plugin
->
option_defaults
,
$this
->
defaults
);
//Load plugin class and populate defaults
if
(
is_object
(
$this
->
plugin
)
&&
is_array
(
$this
->
plugin
->
option_defaults
)
)
$this
->
defaults
=
array_merge
(
$this
->
plugin
->
option_defaults
,
$this
->
defaults
);
}
/**
* Render widget
* @param array $args
* @param array $instance
* @uses taxonomy_dropdown_widget_plugin
* @uses wp_parse_args
* @uses apply_filters
* @return string or null
*/
public
function
widget
(
$args
,
$instance
)
{
//Get plugin class for default options and to build widget
global
$taxonomy_dropdown_widget_plugin
;
if
(
!
is_a
(
$taxonomy_dropdown_widget_plugin
,
'taxonomy_dropdown_widget_plugin'
)
)
$taxonomy_dropdown_widget_plugin
=
new
taxonomy_dropdown_widget_plugin
;
//Options
// Options
$instance
=
wp_parse_args
(
$instance
,
$this
->
defaults
);
extract
(
$args
);
extract
(
$instance
);
//Widget
if
(
$widget
=
$t
axonomy_dropdown_widget_
plugin
->
render_dropdown
(
$instance
,
$this
->
number
)
)
{
//Wrapper and title
//
Widget
if
(
$widget
=
$t
his
->
plugin
->
render_dropdown
(
$instance
,
$this
->
number
)
)
{
//
Wrapper and title
$output
=
$before_widget
;
if
(
!
empty
(
$title
)
)
$output
.
=
$before_title
.
apply_filters
(
'taxonomy_dropdown_widget_title'
,
'<label for="taxonomy_dropdown_widget_dropdown_'
.
$this
->
number
.
'">'
.
$title
.
'</label>'
,
$this
->
number
)
.
$after_title
;
//Widget
//
Widget
$output
.
=
$widget
;
//Wrapper
//
Wrapper
$output
.
=
$after_widget
;
echo
$output
;
...
...
@@ -407,16 +402,10 @@ class taxonomy_dropdown_widget extends WP_Widget {
* Options sanitization
* @param array $new_instance
* @param array $old_instance
* @uses taxonomy_dropdown_widget_plugin
* @return array
*/
public
function
update
(
$new_instance
,
$old_instance
)
{
//Get plugin class for sanitization function
global
$taxonomy_dropdown_widget_plugin
;
if
(
!
is_a
(
$taxonomy_dropdown_widget_plugin
,
'taxonomy_dropdown_widget_plugin'
)
)
$taxonomy_dropdown_widget_plugin
=
new
taxonomy_dropdown_widget_plugin
;
return
$taxonomy_dropdown_widget_plugin
->
sanitize_options
(
$new_instance
);
return
$this
->
plugin
->
sanitize_options
(
$new_instance
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment