Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Cannon michael-cannon

View GitHub Profile
@michael-cannon
michael-cannon / tw_remove_menu_pages.php
Created Sep 25, 2013
Remove custom post type submenu pages.
View tw_remove_menu_pages.php
<?php
function tw_remove_menu_pages() {
// remove testimonials menu section
// remove_menu_page( 'edit.php?post_type=testimonials-widget' );
// remove categories
remove_submenu_page( 'edit.php?post_type=testimonials-widget', 'edit-tags.php?taxonomy=category&amp;post_type=testimonials-widget' );
// remove tags
@michael-cannon
michael-cannon / twp_remove_donate.php
Created Sep 10, 2013
How do you remove the donate button from Testimonials Widget Premium?
View twp_remove_donate.php
<?php
add_action( 'plugins_loaded', 'twp_remove_donate', 25 );
function twp_remove_donate() {
global $TW_Premium;
remove_filter( 'plugin_row_meta', array( $TW_Premium, 'plugin_row_meta' ), 10, 2 );
}
?>
View cbqe_get_post_types_args.php
<?php
add_filter( 'cbqe_get_post_types_args', array( $this, 'get_post_types_args' ) );
public function get_post_types_args( $args ) {
$args[ 'exclude_from_search' ] = true;
return $args;
}
?>
View cbqe_quick_edit_custom_box_field.php
<?php
add_filter( 'cbqe_quick_edit_custom_box_field', array( $this, 'quick_edit_custom_box_field' ), 10, 5 );
public function quick_edit_custom_box_field( $input, $field_type, $field_name, $options, $bulk_mode ) {
$result = '';
switch ( $field_type ) {
case 'date':
$result = '<input type="text" class="datepicker" name="' . $field_name . '" autocomplete="off" />';
break;
View cbqe_quick_scripts_quick.php
<?php
add_filter( 'cbqe_quick_scripts_quick', array( $this, 'scripts_quick' ), 10, 6 );
public function scripts_quick( $scripts_quick, $post_type, $column_name, $field_name, $field_type, $field_name_var ) {
switch ( $field_type ) {
case 'date':
$scripts_quick[ $column_name . '1' ] = "var {$field_name_var} = $( '.column-{$column_name}', post_row ).text();";
$scripts_quick[ $column_name . '2' ] = "$( ':input[name={$field_name}]', edit_row ).val( {$field_name_var} );";
break;
}
View cbqe_quick_scripts_extra.php
<?php
add_filter( 'cbqe_quick_scripts_extra', array( $this, 'scripts_extra' ), 10, 6 );
public function scripts_extra( $scripts_extra, $post_type, $column_name, $field_name, $field_type, $field_name_var ) {
switch ( $field_type ) {
case 'date':
$key = Custom_Bulkquick_Edit::get_field_key( $post_type, $field_name );
$date_format = cbqe_get_option( $key, 'mm/dd/yy' );
$scripts_extra[ $column_name ] = "$( '.datepicker' ).datepicker({ dateFormat: '{$date_format}' });";
View cbqe_quick_scripts_bulk.php
<?php
add_filter( 'cbqe_quick_scripts_bulk', array( $this, 'scripts_bulk' ), 10, 6 );
public function scripts_bulk( $scripts_bulk, $post_type, $column_name, $field_name, $field_type, $field_name_var ) {
switch ( $field_type ) {
case 'date':
$scripts_bulk[ $column_name ] = "'{$field_name}': bulk_row.find( 'input[name={$field_name}]' ).val()";
break;
}
@michael-cannon
michael-cannon / custom_bulkquick_edit_manage_posts_custom_column_field_type.php
Created Aug 25, 2013
Filter `custom_bulkquick_edit_manage_posts_custom_column_field_type`. Customize post type column contents by `field_type`.
View custom_bulkquick_edit_manage_posts_custom_column_field_type.php
<?php
add_filter( 'custom_bulkquick_edit_manage_posts_custom_column_field_type', 'manage_posts_custom_column_field_type', 10, 4 );
public function manage_posts_custom_column_field_type( $current, $field_type, $column, $post_id ) {
$result = '';
switch ( $field_type ) {
case 'date':
$result = $current;
break;
}
@michael-cannon
michael-cannon / custom_bulkquick_edit_settings_display_setting.php
Created Aug 25, 2013
Filter `custom_bulkquick_edit_settings_display_setting`. Display the additional field input types offered.
View custom_bulkquick_edit_settings_display_setting.php
<?php
add_filter( 'custom_bulkquick_edit_settings_display_setting', 'display_setting', 10, 2 );
public function display_setting( $args, $input ) {
$content = '';
extract( $args );
if ( is_null( $input ) ) {
$options = get_option( self::ID );
} else {
@michael-cannon
michael-cannon / custom_bulkquick_edit_settings_as_types.php
Created Aug 25, 2013
Filter `custom_bulkquick_edit_settings_as_types`. Modify the field input types offered.
View custom_bulkquick_edit_settings_as_types.php
<?php
add_filter( 'custom_bulkquick_edit_settings_as_types', 'settings_as_types' );
public function settings_as_types( $as_types ) {
$as_types['date'] = esc_html__( 'As date' );
return $as_types;
}
?>