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 | |
/*there are eight magical constant that changes depanding on where they are used | |
__LINE__ The current line number of the file. | |
__FILE__ The full path and filename of the file with symlinks resolved. If used inside an include, the name of the included file is returned. | |
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. | |
__FUNCTION__ The function name. |
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
/* Enable Shortcode In Wordpress Widget Area */ | |
//Just Paste the code to functions.php file and use shortcode | |
add_filter('widget_text', 'do_shortcode'); | |
//Enable PHP code in Wordpress widget area | |
//just paste the code functions.php file and see the result | |
add_filter('widget_text','execute_php',100); |
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 remove_default_widgets() { | |
unregister_widget('widget_class_name'); | |
unregister_widget('another_class_name'); | |
} | |
add_action( 'widgets_init', 'remove_default_widgets' ); | |
The class names of the all widget is here | |
WP_Widget_Pages = Pages Widget | |
WP_Widget_Calendar = Calendar Widget |
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
if( ! function_exists('function_name') ){ | |
function function_name(){ | |
register_widget('class_name'); | |
} | |
add_action('widgets_init', 'function_name'); | |
} | |
class class_name extends WP_Widget{ | |
function __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 | |
$input = '<button name="submit">Delere</button>@copy;'; | |
echo htmlentities($input); | |
echo '<br>'; | |
?> | |
<?php | |
//encode a html code to string for all the charecter | |
$str = "A 'quote' is <b>bold</b>"; | |
// Outputs: A 'quote' is <b>bold</b> |
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 | |
/* | |
php method chaining is a technic which we can use for make your program more small. for this you have to return all the chained method all the class for this you have to use return $this; | |
*/ | |
class Calculator{ | |
private $num1; | |
private $num2; | |
private $result; | |
public function Set($num1, $num2){ |
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
Pixabay: http://pixabay.com/ | |
FreeImages: http://www.freeimages.com/ | |
Magdeleine: http://magdeleine.co/ | |
Resplashed: http://www.resplashed.com/ | |
Life Of Pix: http://www.lifeofpix.com/ | |
PicoGraphy: http://picography.co/ | |
ISO Republic: http://isorepublic.com/ | |
Designers’ Pics: http://www.designerspics.com/ | |
Camarama: http://www.camarama.de/ | |
StokPic: http://stokpic.com/ |
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
//Adding a custom metabox | |
function custom_meta_box_markup($object) | |
{ | |
wp_nonce_field(basename(__FILE__), "meta-box-nonce"); | |
?> | |
<div> | |
<label for="meta-box-text">Text</label> | |
<input name="meta-box-text" type="text" value="<?php echo get_post_meta($object->ID, "meta-box-text", 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
//This is for a option panel menu | |
function mytheme_admin_menu(){ | |
add_menu_page('MyTheme Options Page', 'MyTheme Options', 'manage_options', 'myoptions', 'myoption_cb', get_template_directory_uri() . '/img/search_icon.png'); | |
add_submenu_page('myoptions', 'MyTheme Options Page', 'Generel Options', 'manage_options', 'myoptions', 'myoption_cb'); | |
add_submenu_page('myoptions', 'MyTheme Generel Options', 'Header Options', 'manage_options', 'myoption_generel', 'myoption_generel_cb'); | |
} | |
add_action('admin_menu', 'mytheme_admin_menu'); |
OlderNewer