Skip to content

Instantly share code, notes, and snippets.

<?php
//add new custom control type switch
if(class_exists( 'WP_Customize_control')):
class Doctorial_WP_Customize_Switch_Control extends WP_Customize_Control {
public $type = 'switch';
public function render_content() {
?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span>
PHP Coding Standards
----------------------
Single and Double Quotes
echo '<a href="/static/link" title="Yeah yeah!">Link name</a>'; // if all are static
echo "<a href='$link' title='$linktitle'>$linkname</a>"; if mix of variable and string
---------------------
give [tab] when write any variable
------------
// load more post function.php
add_action('wp_ajax_load_posts_by_ajax', 'load_posts_by_ajax_callback');
add_action('wp_ajax_nopriv_load_posts_by_ajax', 'load_posts_by_ajax_callback');
function load_posts_by_ajax_callback() {
check_ajax_referer('load_more_posts', 'security');
$paged = $_POST['page'];
$newsletter_lists = get_posts(array('post_type'=>'newsletter','posts_per_page' => 8,'paged' => $paged,));
if ( $newsletter_lists ) {
// get thumbanil url
function get_thumbanil_url($post,$image_size){
if ( has_post_thumbnail($post->ID) ) {
$thumbnail_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),$image_size, true );
$thumb_url = $thumbnail_url[0];
}
else{
$thumb_url = '';
}