This file contains 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
function my_columns_head($defaults) { | |
$defaults['col_slug'] = 'Column Name'; | |
return $defaults; | |
} | |
// SHOW THE FEATURED IMAGE | |
function my_columns_content($column_name, $post_ID) { | |
if ($column_name == 'col_slug') { | |
echo 'Column Value'; | |
} |
This file contains 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
function add_TAX_columns($columns){ | |
$columns['foo'] = 'Foo'; | |
return $columns; | |
} | |
add_filter('manage_edit-TAX_columns', 'add_TAX_columns'); | |
function add_TAX_column_content($content,$column_name,$term_id){ | |
$term= get_term($term_id, 'tax_slug'); | |
switch ($column_name) { | |
case 'foo': |
This file contains 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
function nok_add_attarctions_cpt() { | |
$labels = array( | |
'name' => _x( 'Attractions', 'Post Type General Name', 'nok' ), | |
'singular_name' => _x( 'Attraction', 'Post Type Singular Name', 'nok' ), | |
'menu_name' => __( 'Attractions', 'nok' ), | |
'name_admin_bar' => __( 'Attraction', 'nok' ), | |
'archives' => __( 'Item Archives', 'nok' ), | |
'parent_item_colon' => __( 'Parent Item:', 'nok' ), | |
'all_items' => __( 'All Items', 'nok' ), |
This file contains 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
if ( ! function_exists( 'nok_area_type' ) ) { | |
// Register Custom Taxonomy | |
function nok_area_type() { | |
$labels = array( | |
'name' => _x( 'Area Types', 'Taxonomy General Name', 'nok' ), | |
'singular_name' => _x( 'Area Type', 'Taxonomy Singular Name', 'nok' ), | |
'menu_name' => __( 'Area Type', 'nok' ), | |
'all_items' => __( 'All Items', 'nok' ), |
This file contains 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
add_action( 'quick_edit_custom_box', 'display_custom_quickedit_featured', 10, 2 ); | |
function display_custom_quickedit_featured( $column_name, $post_type ) { | |
static $printNonce = TRUE; | |
if ( $printNonce ) { | |
$printNonce = FALSE; | |
wp_nonce_field( plugin_basename( __FILE__ ), 'post_edit_nonce' ); | |
} | |
?> |
This file contains 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
function get_user_image($user) { | |
$img = get_field('author_image', 'user_'.$user->id); | |
if (!empty($img)) { | |
$img = wp_get_attachment_image($img['ID'], 'user_avatar'); | |
} else { | |
$img = get_avatar( $user->ID, 130); | |
} | |
return $img; | |
} |
This file contains 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
function import_featured_image($image_url, $caption, $post_id) { | |
$upload_dir = wp_upload_dir(); | |
$image_data = file_get_contents($image_url); | |
$filename = basename($image_url); | |
if(wp_mkdir_p($upload_dir['path'])) | |
$file = $upload_dir['path'] . '/' . $filename; | |
else | |
$file = $upload_dir['basedir'] . '/' . $filename; | |
file_put_contents($file, $image_data); |
This file contains 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
function get_videos_from_youtube_api($num) { | |
if ( false === ( $data = get_transient( 'grafa-youtube-result' ) ) ) { | |
$key = 'Youtube-Key'; | |
$channel = 'Channel-ID'; | |
// $url = "https://www.googleapis.com/youtube/v3/playlistItems?key=$key&playlistId=$channel&part=snippet,id&order=date&maxResults=20"; | |
$url = "https://www.googleapis.com/youtube/v3/search?key=$key&channelId=$channel&part=snippet,id&order=date&maxResults=20"; | |
$data = file_get_contents($url); | |
set_transient( 'grafa-youtube-result', $data, 4 * HOUR_IN_SECONDS ); |
This file contains 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
add_action('wp_login','user_last_login', 0, 2); | |
function user_last_login($login, $user) { | |
$user = get_user_by('login',$login); | |
$now = time(); | |
update_usermeta( $user->ID, 'user_last_login', $now ); | |
} |
This file contains 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
// Get all playlists in the channel | |
function bio_youtube_get_playlists() { | |
$lists = array(); | |
$key = 'Youtube-API-Key'; | |
$channel = 'Channel-ID'; | |
$url = "https://www.googleapis.com/youtube/v3/playlists?key=$key&channelId=$channel&part=snippet,id&order=date&maxResults=20"; | |
$data = file_get_contents($url); | |
if (!empty($data)) { | |
$data_struct = json_decode($data); | |
if (is_array($data_struct->items)) { |
OlderNewer