Skip to content

Instantly share code, notes, and snippets.

View Hein-Thu-Ya's full-sized avatar
👨‍💻
Web Developer

Hein Thu Ya Hein-Thu-Ya

👨‍💻
Web Developer
  • Yangon, Myanmar
View GitHub Profile
@Hein-Thu-Ya
Hein-Thu-Ya / Response.php
Created November 1, 2022 08:28 — forked from jeffochoa/Response.php
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@Hein-Thu-Ya
Hein-Thu-Ya / category-name.php
Last active July 28, 2021 17:04
Display Category Name in WordPress
<?php
if ( is_singular() ) {
sinatra_entry_meta_category( ' ', false );
} else {
if ( 'blog-horizontal' === sinatra_get_article_feed_layout() ) {
sinatra_entry_meta_category( ' ', false );
} else {
sinatra_entry_meta_category( ', ', false );
}
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #FF9000; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
// Add functions.php file
function wpb_widgets_init() {
register_sidebar( array(
'name' => 'Home Page Sidebar',
'id' => 'custom-header-widget',
'before_widget' => '<div class="col-md-5">',
'after_widget' => '</div>',
'before_title' => '<div class="aerial_fan"><h2>',
'after_title' => '</h2></div>',
// Recent Posts With Image Widget
Class My_Recent_Posts_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'widget_recent_entries',
'description' => __( 'The most recent posts with image ' ),
'customize_selective_refresh' => true,
);
parent::__construct( 'recent-posts', __( 'Recent Post with Image' ), $widget_ops );
// Add UserFactory.php file
$factory->define(Profile::class, function (Faker $faker) {
return [
'user_id' => User::all()->random()->id,
'address' => $faker->address
];
});
// Add DatabaseSeeder.php file
factory('App\Profile', 20)->create();
// Add the selective part
$wp_customize->selective_refresh->add_partial( 'your_theme_second_logo', array(
'selector' => '#yourID', // You can also select a css class
) );
//custom recent post widget area
/**
* Extend Recent Posts Widget
*
* Adds different formatting to the default WordPress Recent Posts Widget
*/
Class My_Recent_Posts_Widget extends WP_Widget_Recent_Posts {
function widget($args, $instance) {
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<div class="promo-item img-fluid" style="background-image: url(
<?php if(has_post_thumbnail()) : ?>
<?php echo $thumb['0']; ?>
<?php else: ?>
<?php echo get_stylesheet_directory_uri(); ?>/img/d.jpg;
<?php endif; ?>
)">
</div>