Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
tojibon
/
wp-unique-page-sidebar-autofill.js
Last active
Aug 29, 2015
Star
0
Fork
0
Star
Code
Revisions
2
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Auto fill input values for WordPress Unique Page Sidebars [Plugins] when creating a dynamic sidebar with default values
Raw
wp-unique-page-sidebar-autofill.js
/*
---------------------------------------------------------------------------------------
Auto fill input values for WordPress Unique Page Sidebars [Plugins] when creating a dynamic sidebar with default values
---------------------------------------------------------------------------------------
*/
jQuery
(
document
)
.
ready
(
function
(
$
)
{
//Finding all inputs from unique page sidebars when creating a sidebar
$
(
"input[id^=ups_sidebars]"
)
.
each
(
function
(
k
,
v
)
{
//Finding current input fields id
id
=
$
(
this
)
.
attr
(
'id'
)
;
//Check if it has a default value already
if
(
$
(
this
)
.
val
(
)
==
''
)
{
//Matching if it is the before_title field
before_title
=
id
.
match
(
/
\b
before_title
/
)
;
if
(
before_title
)
{
$
(
this
)
.
val
(
'<h3 class="widget-title">'
)
;
}
//Matching if it is the after_title field
after_title
=
id
.
match
(
/
\b
after_title
/
)
;
if
(
after_title
)
{
$
(
this
)
.
val
(
'</h3>'
)
;
}
//Matching if it is the before_widget field
before_widget
=
id
.
match
(
/
\b
before_widget
/
)
;
if
(
before_widget
)
{
$
(
this
)
.
val
(
'<div id="%1$s" class="widget %2$s">'
)
;
}
//Matching if it is the after_widget field
after_widget
=
id
.
match
(
/
\b
after_widget
/
)
;
if
(
after_widget
)
{
$
(
this
)
.
val
(
'</div>'
)
;
}
}
}
)
;
}
)
;
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.