Skip to content

Instantly share code, notes, and snippets.

/**
* Answer 7
*/
#include <stdio.h>
void main()
{
int i, j;
int num[3][4] = {
{10,12,14,16},
@obiPlabon
obiPlabon / wp-async-script-loader.php
Created May 15, 2017 11:20
Modify script tag in WordPress to load scripts in async mood or defer mood
<?php
/**
* Add async boolean attribute to script tag
* @param string $tag Default script tag
* @return string Modified script tag
*/
function omm_add_async_loading( $tag ) {
return str_replace( '<script', '<script async', $tag );
}
add_filter( 'script_loader_tag', 'omm_add_async_loading' );
<?php
// Way Two
/**
* Set comment textarea to the bottom of comment form
* only works with WordPress version >= 4.4
* @param array $fields Comment form inputs
*/
function op_change_comment_textarea_position( $fields ) {
$comment = array('comment' => $fields['comment'] );
unset( $fields['comment'] );
<?php
add_filter( 'product_type_options', 'op_set_product_type_options_default' );
/**
* Set virtual and downloadable checkbox to checked
* @param array $options Checkbox options
* @return array Updated options
*/
function op_set_product_type_options_default( $options ) {
$options['virtual']['default'] = 'yes';
<?php
/**
* Plugin Name: EDD Heartbeat API test plugin
* Description: Demonstrates how to use the Heartbeat API to update the payments count on the dashboard
*/
// Load the heartbeat JS
function edd_heartbeat_enqueue( $hook_suffix ) {
// Make sure the JS part of the Heartbeat API is loaded.
wp_enqueue_script( 'heartbeat' );
@obiPlabon
obiPlabon / mailchimp-url.md
Last active September 25, 2017 09:44
Simple way to figure out MailChimp subscribe form URL for AjaxChimp plugin (https://github.com/scdoshi/jquery-ajaxchimp)

Figuring Out MailChimp Subscribe Form URL

First of all check this article on MailChimp knowledge base Host Your Own Signup Form. If you're at point 1, then take a look at the following picture. We need those 3 highlighted items to form a URL.

Form code

Copy those items and form a URL like the following:

http://mailchimp.us8.list-manage.com/subscribe/post??u=a123cd45678ef90g7h1j7k9lm&amp;id=ab2c468d10
@obiPlabon
obiPlabon / wp-attachment-query-args-update.php
Last active April 11, 2018 06:09
Modify WordPress attachment ajax query
<?php
/**
* Show last 5 attachments in media popup
*/
/**
* Attachment query arguments
* @param array $args Query arguments
* @return array Update query argumnets
*/
@obiPlabon
obiPlabon / wc-block-add-to-cart-sl2.php
Last active September 20, 2023 08:18
Prevent WooCommerce to add more than 1 item in cart
<?php
/**
* Simple & concise Solution
*/
function op_block_add_to_cart() {
wc_add_notice( sprintf(
/** translators: %1$s is cart url, %2$s is checkout url */
esc_html__( 'You cannot purchase more than 1 item at a time. %1$s or %2$s', 'op' ),
'<a href="' . esc_url( wc_get_cart_url() ) . '">' . esc_html__( 'View cart', 'op' ) . '</a>',
'<a href="' . esc_url( wc_get_checkout_url() ) . '">' . esc_html__( 'checkout', 'op' ) . '</a>'
@obiPlabon
obiPlabon / wp-time-constants.txt
Created October 19, 2017 11:08
WordPress time constants added in 3.5
// WordPress Time Constants
MINUTE_IN_SECONDS = 60 (seconds)
HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS
DAY_IN_SECONDS = 24 * HOUR_IN_SECONDS
WEEK_IN_SECONDS = 7 * DAY_IN_SECONDS
MONTH_IN_SECONDS = 30 * DAY_IN_SECONDS
YEAR_IN_SECONDS = 365 * DAY_IN_SECONDS
@obiPlabon
obiPlabon / bypass-wp-theme-update.php
Last active November 6, 2017 20:56
Bypass WordPress theme update notification. বাংলা টিউটোরিয়ালঃ http://obiplabon.im/745/bypass-wordpress-theme-update-notification/
<?php
/**
* Disable theme update notification
*
* Disabled this notification because there is a theme
* in WP theme directory with same name.
* We'll do this based on author name as author won't be same
*
* @param array $theme Installed themes information
* @return array Modified information