Skip to content

Instantly share code, notes, and snippets.

View fencermonir's full-sized avatar

Md. Monir Hossain fencermonir

View GitHub Profile
@fencermonir
fencermonir / functions.php
Created August 30, 2018 09:37 — forked from dasbairagya/functions.php
Add a WYSIWYG Field to WooCommerce Product Category Page
<?php
/********************************************Add a custom filed in the categoy*************************/
add_action( 'init', 'wpm_product_cat_register_meta' );
/**
* Register details product_cat meta.
*
* Register the details metabox for WooCommerce product categories.
*
*/
function wpm_product_cat_register_meta() {
@fencermonir
fencermonir / wysiwyg-meta-box.php
Created August 30, 2018 07:21 — forked from retgef/wysiwyg-meta-box.php
How to add a Wordpress WYSIWYG editor to a meta box.
<?php
define('WYSIWYG_META_BOX_ID', 'my-editor');
define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different
define('WYSIWYG_META_KEY', 'extra-content');
add_action('admin_init', 'wysiwyg_register_meta_box');
function wysiwyg_register_meta_box(){
add_meta_box(WYSIWYG_META_BOX_ID, __('WYSIWYG Meta Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');
}
@fencermonir
fencermonir / term-meta.php
Created August 30, 2018 07:18 — forked from chrisdc/term-meta.php
Add a custom meta box to the new/edit category pages. The meta data is saved to the array term_meta[], which can handle further fields in the future. Based on: https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/
<?php
/**
* Add a custom meta box to the new/edit category pages.
* The meta data is saved to the array term_meta[], which can handle further
* fields in the future.
*
* Based on: https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/
*/
/**
@fencermonir
fencermonir / browser-body-class.php
Created August 28, 2018 07:56 — forked from james2doyle/browser-body-class.php
Add a custom body class to WordPress for the current browser being used. No external frameworks or plugins.
<?php
function custom_body_classes($classes)
{
// the list of WordPress global browser checks
// https://codex.wordpress.org/Global_Variables#Browser_Detection_Booleans
$browsers = ['is_iphone', 'is_chrome', 'is_safari', 'is_NS4', 'is_opera', 'is_macIE', 'is_winIE', 'is_gecko', 'is_lynx', 'is_IE', 'is_edge'];
// check the globals to see if the browser is in there and return a string with the match
$classes[] = join(' ', array_filter($browsers, function ($browser) {
@fencermonir
fencermonir / wp-conditional-enqueue-new-way.php
Created August 28, 2018 06:58 — forked from obiPlabon/wp-conditional-enqueue-new-way.php
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' );
@fencermonir
fencermonir / functions.php
Created August 28, 2018 06:54 — forked from wpscholar/functions.php
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
<?php
/* =============================================================================
MCE FILTERS
========================================================================== */
/**
http://wp.tutsplus.com/tutorials/theme-development/adding-custom-styles-in-wordpress-tinymce-editor/
*
inline
Name of the inline element to produce for example “span”. The current text selection will be wrapped in this inline element.
@fencermonir
fencermonir / bootstrapCDN.html
Created February 21, 2018 03:56 — forked from planetoftheweb/bootstrapCDN.html
Bootstrap 3 CDN Page Code
<!-- HEAD SECTION -->
<!-- IE Edge Meta Tag -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<?php
$caseNo = 0;
foreach (range(1, 9) as $numberOne) {
$makeNumberOne = ($numberOne * 100) + 62;
foreach (range(1, 9) as $numberTwo) {
<?php
/**
* Show posts which are only under uncategorized term
* 1 is the id of Uncategorized term
*/
function op_show_only_uncategorized( $query ) {
if ( is_admin() || ! $query->is_main_query() || ! $query->is_category( 1 ) ) {
return;
}