CodeHint


Wordpress (45 items)



    is_user_logged_in()

Returns true if user is logged in

  Edit
    wp_get_current_user()
// Returns current user
$current_user = wp_get_current_user();
/**
 * @example Safe usage: $current_user = wp_get_current_user();
 * if ( !($current_user instanceof WP_User) )
 * return;
 */
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID . '<br />';
print_r(wp_get_current_user()->roles);
  Edit
    get_current_user_id()

Returns current user id

  Edit
    get_site_url()

returns get_option( 'siteurl' ) as string

  Edit
    home_url()

Returns home url

  Edit
    get_permalink()

Returns permalink as string

  Edit
    get_bloginfo()
<?php
// Returns the name of the blog
 $blog_title = get_bloginfo( 'name' ); 
?>
  Edit
    wp_login_url()

Returns login url

  Edit
    wp_logout_url()

Returns logout url

  Edit
    wp_redirect($url)
<?php
// Redirects to specific url
if ( wp_redirect( $url ) ) {
    exit;
}
?>
  Edit
    wp_safe_redirect( $location, $status )
<?php
// If the host is not allowed, then the redirect is to wp-admin on the siteurl instead. This prevents malicious redirects which redirect to another host, but only used in a few places. 
if ( wp_redirect( $url ) ) {
    exit;
}
?>
  Edit
    the_content()

Echoes post content

  Edit
    the_ID()

Echoes post id

  Edit
    get_option('blogname')

Get blogname option

  Edit
    is_home

Checks if its home

  Edit
    is_page()

Checks if its page

  Edit
    is_front_page()

Checks if its front page

  Edit
    is_single()

Checks if its single

  Edit
    is_category()

Checks if its category

  Edit
    is_archive()

Checks if its archive

  Edit
    load_plugin_textdomain()

Load plugin textdomain kkkkkkk

  Edit
    wp_list_pages( $args )
<?php 
// Show a list of pages as links with these args
$args = array(
	'depth'        => 0,
	'show_date'    => '',
	'date_format'  => get_option('date_format'),
	'child_of'     => 0,
	'exclude'      => '',
	'include'      => '',
	'title_li'     => __('Pages'),
	'echo'         => 1,
	'authors'      => '',
	'sort_column'  => 'menu_order, post_title',
	'link_before'  => '',
	'link_after'   => '',
	'walker' => '' ); 
?>
<ul>
  <?php wp_list_pages('sort_column=post_date&show_date=created'); ?>
</ul>
  Edit
    wp_list_categories($defaults)
<?php
// Returns a list of categories
$defaults = array(
        'child_of'            => 0,
        'current_category'    => 0,
        'depth'               => 0,
        'echo'                => 1,
        'exclude'             => '',
        'exclude_tree'        => '',
        'feed'                => '',
        'feed_image'          => '',
        'feed_type'           => '',
        'hide_empty'          => 1,
        'hide_title_if_empty' => false,
        'hierarchical'        => true,
        'order'               => 'ASC',
        'orderby'             => 'name',
        'separator'           => '<br />',
        'show_count'          => 0,
        'show_option_all'     => '',
        'show_option_none'    => __( 'No categories' ),
        'style'               => 'list',
        'taxonomy'            => 'category',
        'title_li'            => __( 'Categories' ),
        'use_desc_for_title'  => 1,
    );
?>
  Edit
    wp_register_script ($handle, $src, $deps, $ver, $in_footer)

Registers a script to be enqueued later using the wp_enqueue_script() function

  Edit
    wp_enqueue_script ($handle, $src, $deps, $ver, $in_footer)

Registers the script if $src provided (does NOT overwrite), and enqueues it

  Edit
    wp_get_attachment_image_src ($thumb_id, $size )

wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );

  Edit
    has_post_thumbnail()

Verify if post has thumbnail

  Edit
    add_action ($name, $function, $priority, $args)

Hooks a function on to a specific action

  Edit
    do_action ($name, $args)

Execute functions hooked on a specific action hook

  Edit
    add_filter ($name,$function,$priority,$args)

Hook a function or method to a specific filter action

  Edit
    apply_filter ($name)

Call the functions added to a filter hook.

  Edit
    register_activation_hook ($file, $function)

When a plugin is activated, the action ‘activate_PLUGINNAME’ hook is called. In the name of this hook, PLUGINNAME is replaced with the name of the plugin, including the optional subdirectory. For example, when the plugin is located in wp-content/plugins/sampleplugin/sample.php, then the name of this hook will become ‘activate_sampleplugin/sample.php’. When the plugin consists of only one file and is (as by default) located at wp-content/plugins/sample.php the name of this hook will be ‘activate_sample.php’.

  Edit
    register_deactivation_hook ($file,$function)

When a plugin is deactivated, the action ‘deactivate_PLUGINNAME’ hook is called. In the name of this hook, PLUGINNAME is replaced with the name of the plugin, including the optional subdirectory. For example, when the plugin is located in wp-content/plugins/sampleplugin/sample.php, then the name of this hook will become ‘deactivate_sampleplugin/sample.php’.

  Edit
    global $wpdb

Wordpress database initial declaration

  Edit
    maybe_serialize($data)

Serialize data if is an array or an object

  Edit
  Functions.php
current_time= retrieves current time
add_option, update_option, get_option = functions to create, update, get
force_ssl_login = requires SSL login
wp_nonce_ays = displays are you sure
  Edit
  Formatting.php
is_mail = check if is email
esc_attr = escape string
wp_specialchars = converts characters to html entities
  Edit
  Pluggable.php
wp_mail = sends email
get_userdata = get userdata
get_currentuserinfo = get currentuserinfo
wp_signon = sign on 
wp_logout = logout
wp_redirect = redirect
get_avatar = get avatar
  Edit
    add_filter('show_admin_bar', '__return_false')

Hides admin bar. Do it in functions.php of your theme

  Edit
    define('DISABLE_WP_CRON', 'true')

WordPress uses a file called wp-cron.php as a virtual cron job, or scheduled task in order to automate things like publishing scheduled posts, checking for plugin or theme updates, sending email notifications and more. By default WordPress is setup to call wp-cron.php everytime someone visits your WordPress website when a scheduled task is present, to basically ask "is it time to do anything yet?". On low traffic sites this is perfectly fine, but when visitors roll in, checking multiple times for scheduled tasks can be very inefficient and lead to resource usage problems for your server, plus make your website load slower.

  Edit
    $page = get_query_var('page')

Get query var, in this case the url page

  Edit
    $parent = get_cat_ID('blog’)

Get the category ID

  Edit
  Upload image on admin
var attachment = frame.state().get('selection').first().toJSON();
  Edit
    add_meta_box($id, $title, $callback, $screen, $context, $priority, $callback_args)

Adds a meta box to one or more screens: id, title, callback, screen, context, priority, callback_args

  Edit
    add_action($action, $function)

Hook to specific action. Ex: add_action('admin_init', 'add_post_meta_boxes').

  Edit