Entries by Vectorilo

LESS (stylesheet language)

LESS (Leaner CSS) is a dynamic stylesheet language designed by Alexis Sellier. It is influenced by Sass and has influenced the newer “SCSS” syntax of Sass, which adapted its CSS-like block formatting syntax. Variables LESS allows variables to be defined. LESS variables are defined with an at sign(@). Variable assignment is done with a colon […]

Validating Sanitizing and Escaping User Data

$title = sanitize_text_field( $_POST[‘title’] ); update_post_meta( $post->ID, ‘title’, $title ); Behinds the scenes, the function does the following: Checks for invalid UTF-8 (uses wp_check_invalid_utf8()) Converts single < characters to entity Strips all tags Remove line breaks, tabs and extra white space Strip octets The sanitize_*() class of helper functions are super nice for us, as […]

Use of Referencing in php

There are advantages of using references, for example you don’t have to return anything from the function, nor do you have to look to define them as globally accessible. EXAMPLE: function lowercase(&$string){ $string = strtolower($string); } $name = ‘SAJU’; lowercase($name); echo $name; // returns saju

How to Display Any RSS Feed on Your WordPress Blog

<h2><?php _e( ‘Recent news from Some-Other Blog:’, ‘my-text-domain’ ); ?></h2> <?php // Get RSS Feed(s) include_once( ABSPATH . WPINC . ‘/feed.php’ ); // Get a SimplePie feed object from the specified feed source. $rss = fetch_feed( ‘http://www.wpbeginner.com/feed/’ ); if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly // […]

Check has post next and previous link

<?php $previous_post = get_adjacent_post(false, ”, true); $next_post = get_adjacent_post(false, ”, false); ?> <ul> <?php if ($previous_post): // if there are older articles ?> <li class=”prev”>Previous post: <a href=”<?php echo make_href_root_relative(get_permalink($previous_post)); ?>”><?php echo get_the_title($previous_post); ?></a></li> <?php endif; ?> <?php if ($next_post): // if there are newer articles ?> <li class=”next”>Next post: <a href=”<?php echo make_href_root_relative(get_permalink($next_post)); ?>”><?php […]

Stylish Checkbox with CSS

STYLE: label { display: inline; } .regular-checkbox { display: none; } .regular-checkbox + label { background-color: #fafafa; border: 1px solid #cacece; box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05); padding: 9px; border-radius: 3px; display: inline-block; position: relative; } .regular-checkbox + label:active, .regular-checkbox:checked + label:active { box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px […]

regular expression syntax in php

Example Description ‘/hello/’ It will match the word hello ‘/^hello/’ It will match hello at the start of a string. Possible matches are hello or helloworld, but not worldhello ‘/hello$/’ It will match hello at the end of a string. ‘/he.o/’ It will match any character between he and o. Possible matches are helo or […]

get_posts() with Taxonomy

$args = array( ‘post_type’ => ‘POST_TYPE’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘TAXONOMY_NAME’, ‘field’ => ‘slug’, ‘terms’ => array( ‘YOUR_TERMS’ ), ‘operator’ => ‘AND’ ) ) ); get_posts( $args ); for more information refer the link http://codex.wordpress.org/Function_Reference/WP_Query#Taxonomy_Parameters