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 __construct() { | |
parent::__construct( | |
// widget ID | |
'hstngr_widget', | |
// widget name | |
__('Hostinger Sample Widget', ' hstngr_widget_domain'), | |
// widget description | |
array( 'description' => __( 'Hostinger Widget Tutorial', 'hstngr_widget_domain' ), ) | |
); | |
} |
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 hstngr_register_widget() { | |
register_widget( 'hstngr_widget' ); | |
} | |
add_action( 'widgets_init', 'hstngr_register_widget' ); | |
class hstngr_widget extends WP_Widget { | |
function __construct() { | |
parent::__construct( |
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 | |
// Hook the 'wp_footer' action, run the function named 'mfp_Add_Text()' | |
add_action("wp_footer", "mfp_Add_Text"); | |
// Hook the 'wp_head' action, run the function named 'mfp_Remove_Text()' | |
add_action("wp_head", "mfp_Remove_Text"); | |
// Define the function named 'mfp_Add_Text('), which just echoes simple text | |
function mfp_Add_Text() |
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: Add Excerpt | |
*/ | |
// Hook the get_the_excerpt filter hook, run the function named mfp_Add_Text_To_Excerpt | |
add_filter("get_the_excerpt", "mfp_Add_Text_To_Excerpt"); | |
// Take the excerpt, add some text before it, and return the new excerpt | |
function mfp_Add_Text_To_Excerpt($old_Excerpt) |
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
// Hook the get_the_excerpt filter hook, run the function named mfp_Add_Text_To_Excerpt | |
add_filter("get_the_excerpt", "mfp_Add_Text_To_Excerpt"); | |
// If today is a Thursday, remove the filter from the_excerpt() | |
if (date("l") === "Thursday") { | |
remove_filter("get_the_excerpt", "mfp_Add_Text_To_Excerpt"); | |
} | |
// Take the excerpt, add some text before it, and return the new excerpt | |
function mfp_Add_Text_To_Excerpt($old_Excerpt) |
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: My First Plugin | |
*/ |
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: My First Plugin | |
Description: This is my first plugin! It makes a new admin menu link! | |
Author: Your Name | |
*/ | |
// Include mfp-functions.php, use require_once to stop the script if mfp-functions.php is not found | |
require_once plugin_dir_path(__FILE__) . 'includes/mfp-functions.php'; |