This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Use the `$admin_page_hook[ $page_slug ]` in the `load-{page}` hook | |
*/ | |
global $admin_page_hooks; | |
if ( !empty( $admin_page_hooks['myplugin-parent'] ) ) { | |
add_action( 'load-' . $admin_page_hooks['myplugin-parent'] . '_page_myplugin-subpage', 'enqueue_myplugin_assets' ); | |
} | |
/** | |
* Or add `$admin_page_hook[ $page_slug ]` when checking the current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* You can hook directly into the `load-{page}` hook for a sub-page with | |
* an action like this. | |
*/ | |
add_action( 'load-myplugin-parent_page_myplugin-subpage', 'enqueue_myplugin_assets' ); | |
/** | |
* Or you can hook into `admin_enqueue_scripts` and check the current | |
* screen to see if we're on the right page. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* You've probably done this before. I know I have. | |
*/ | |
var text = $( '#myid .select a > element' ).text(); | |
newtext = doSomeStuff( text ); | |
$( '#myid .select a > element' ).text( newtext ); | |
$( '#myid .select a > element' ).addClass( 'someClass' ); | |
$( '#myid .select a > element' ).fadeIn(); | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select name="less_tedious"> | |
<?php foreach( $options as $value => $label ) : ?> | |
<option value="<?php echo $value; ?>" <?php selected( $value, $current_value ); ?>"><?php echo $label; ?></option> | |
<?php endforeach; ?> | |
</select> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select name="tedious"> | |
<?php foreach( $options as $value => $label ) : ?> | |
<option value="<?php echo $value; ?>" <?php if ( $value === $current_value ) { echo 'selected="selected"'; } ?>"><?php echo $label; ?></option> | |
<?php endforeach; ?> | |
</select> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Go ahead. Do your fancy shit | |
*/ | |
$your_query = new WP_query( 'post_type' => 'your_cool_post_type' ); | |
while( $your_query->have_posts() ) { | |
$your_query->the_post(); | |
/** | |
* Look at your cool template function. | |
* That looks just like my template function. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set up a global for storing settings in your product | |
* (if you're using classes, store it in a controller) | |
*/ | |
global $myprefix_settings; | |
/** | |
* Set up your own wrapper for accessing settings in | |
* your product | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ( is_category() || is_tag() || is_tax() ) && $summary = term_description() ) : ?> | |
<div class="term-summary"> | |
<?php echo $summary; ?> | |
</div> | |
<?php endif; ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Register a single setting to store all of your options in the database | |
*/ | |
register_setting( 'myslug_option_group', 'myslug', 'myslug_sanitize_options_array' ); | |
/** | |
* Define each of your settings | |
*/ | |
add_settings_field( | |
'name', |
NewerOlder