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
<?php | |
/* | |
Plugin Name: Name Of The Plugin | |
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates | |
Description: A brief description of the Plugin. | |
Version: The Plugin's Version Number, e.g.: 1.0 | |
Author: Name Of The Plugin Author | |
Author URI: http://URI_Of_The_Plugin_Author | |
License: A "Slug" license name e.g. GPL2 | |
*/ |
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
public function widget( $args, $instance ) { | |
extract( $args ); | |
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : ''; | |
$text = isset( $instance['text'] ) ? $instance['text'] : ''; | |
$textarea = isset( $instance['textarea'] ) ?$instance['textarea'] : ''; | |
$select = isset( $instance['select'] ) ? $instance['select'] : ''; | |
$checkbox = ! empty( $instance['checkbox'] ) ? $instance['checkbox'] : false; | |
echo $before_widget; | |
echo '<div class="widget-text wp_widget_plugin_box">'; | |
if ( $title ) { |
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
public function update( $new_instance, $old_instance ) { | |
$instance = $old_instance; | |
$instance['title'] = isset( $new_instance['title'] ) ? wp_strip_all_tags( $new_instance['title'] ) : ''; | |
$instance['text'] = isset( $new_instance['text'] ) ? wp_strip_all_tags( $new_instance['text'] ) : ''; | |
$instance['textarea'] = isset( $new_instance['textarea'] ) ? wp_kses_post( $new_instance['textarea'] ) : ''; | |
$instance['checkbox'] = isset( $new_instance['checkbox'] ) ? 1 : false; | |
$instance['select'] = isset( $new_instance['select'] ) ? wp_strip_all_tags( $new_instance['select'] ) : ''; | |
return $instance; | |
} |
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
public function form( $instance ) { | |
$defaults = array( | |
'title' => '', | |
'text' => '', | |
'textarea' => '', | |
'checkbox' => '', | |
'select' => '', | |
); | |
extract( wp_parse_args( ( array ) $instance, $defaults ) ); ?> | |
<p> |
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
public function __construct() { | |
parent::__construct( | |
'my_custom_widget', | |
__( 'My Custom Widget', 'text_domain' ), | |
array( | |
'customize_selective_refresh' => true, | |
) | |
); | |
} |
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
class My_Custom_Widget extends WP_Widget { | |
public function __construct() { | |
} | |
public function form( $instance ) { | |
} | |
public function update( $new_instance, $old_instance ) { | |
} | |
public function widget( $args, $instance ) { | |
} |
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
<?php | |
/* | |
Plugin Name: Name Of The Plugin | |
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates | |
Description: A brief description of the Plugin. | |
Version: The Plugin's Version Number, e.g.: 1.0 | |
Author: Name Of The Plugin Author | |
Author URI: http://URI_Of_The_Plugin_Author | |
License: A "Slug" license name e.g. GPL2 | |
*/ |
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
// In Between PHP | |
<?php if(condition){ ?> | |
HTML | |
<?php } ?> | |
// In An PHP | |
if(condition){ | |
echo "HTML"; | |
} |
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
Instead of | |
if ( has_post_thumbnail() ) { | |
} | |
use this code | |
$featured_image_url = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ); | |
if ( ! empty( $featured_image_url ) ) { | |
} |
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
$id = get_cat_id('Category-Sample'); | |
$q = "cat=-" . $id; | |
query_posts($q); | |
if (have_posts()) : while (have_posts()) : the_post(); |
NewerOlder