Skip to content

Instantly share code, notes, and snippets.

View obiPlabon's full-sized avatar
🎯
1 goal

Md Obidullah obiPlabon

🎯
1 goal
View GitHub Profile
<?php
/**
* Make custom images sizes selectable
*
* @param array $sizes
* @return array
*/
function op_selectable_image_sizes( $sizes ) {
return array_merge( $sizes, array(
'twentyseventeen-thumbnail-avatar' => __( 'Thumbnail Avatar', 'twentyseventeen' ),
<?php
/**
* World's simplest secondary The Loop
*/
$posts = get_posts( $args );
if ( count( $posts ) ) :
global $post;
foreach ( $posts as $post ) :
<?php
/**
* Show only top level district or division
* that means district without any parent district
*
* @param array $args
* @return array $args
*/
function op_page_attributes_dropdown_pages_args( $args ) {
if ( 'district' === $args['post_type'] ) {
<?php
/**
* Enqueue scripts
*/
function op_enqueue_scripts() {
$suffix = '.min';
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
$suffix = '';
}
wp_enqueue_script(
@obiPlabon
obiPlabon / wc-template-override.php
Last active September 26, 2020 12:50
Helper class to override WooCommerce templates from plugin
<?php
/**
* WooCommerce template overriding class
*
* @author obiPlabon
*/
class WC_Template_Override {
/**
@-webkit-keyframes spin {
100% {
-webkit-transform:rotate(360deg);
transform:rotate(360deg)
}
}
@keyframes spin {
100% {
-webkit-transform:rotate(360deg);
transform:rotate(360deg)
@obiPlabon
obiPlabon / wp-conditional-enqueue-new-way.php
Created February 13, 2018 12:06
Enqueue IE (Internet Explorer) only scripts and stylesheet in WordPress
<?php
function op_enqueue_scripts() {
wp_enqueue_style(
'op-ie8',
get_template_directory_uri() . '/assets/css/ie8.css',
array(),
'0.0.7'
);
wp_style_add_data( 'op-ie8', 'conditional', 'IE 8' );
@obiPlabon
obiPlabon / wp-taxonomy-term-parent-child-relation.php
Last active January 25, 2018 19:07
Restrict hierarchical taxonomy term relation to a certain level.
<?php
/**
* Restrict category term relation to only parent-child
*
* @see https://wpseek.com/hook/post_edit_category_parent_dropdown_args/
* @see https://wpseek.com/hook/taxonomy_parent_dropdown_args//
*
* @param array $args
* @return array Modified arguments
*/
@obiPlabon
obiPlabon / codestar-example.php
Last active January 18, 2018 17:46
Use this condition if you wanna do anything only on static home page
<?php
function op_register_metaboxes( $options ) {
$options = array();
if ( 'page' === get_option( 'show_on_front' )
&& ( $page_id = get_option( 'page_on_front' ) )
&& isset( $_GET['post'] )
&& $_GET['post'] === $page_id ) {
$options[] = array(

Keybase proof

I hereby claim:

  • I am obiplabon on github.
  • I am obiplabon (https://keybase.io/obiplabon) on keybase.
  • I have a public key ASCUf7ssBjxS6J20trTQaOnb6jIOJPeyM9-3pSs9i2V_UAo

To claim this, I am signing this object: {