Skip to content

Instantly share code, notes, and snippets.

View fencermonir's full-sized avatar

Md. Monir Hossain fencermonir

View GitHub Profile
@fencermonir
fencermonir / get_thumbnail_to_category_rest.php
Created September 27, 2021 09:37 — forked from tzkmx/get_thumbnail_to_category_rest.php
Add thumbnail field to WordPress category via REST API
<?php
add_action('rest_api_init', 'register_my_rest_field');
/**
* It depends on term_meta key _thumbnail_id using the metadata API
* for terms. Only plugin I know uses this is Taxonomy Thumbnail:
* https://wordpress.org/plugins/sf-taxonomy-thumbnail/ instead of
* storing metadata for terms in wp_options or custom tables
*/
function register_my_rest_field()
{
@fencermonir
fencermonir / delete_git_submodule.md
Created June 8, 2021 09:12 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@fencermonir
fencermonir / pe-customize-controls.css
Created January 11, 2021 09:48 — forked from OriginalEXE/pe-customize-controls.css
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
@fencermonir
fencermonir / git-cheat-sheet.md
Created December 1, 2020 06:17 — forked from jjjjcccjjf/git-cheat-sheet.md
GIT CHEAT SHEET by TOWER - www.git-tower.com

CREATE

Clone an existing repository

$ git clone ssh://user@domain.com/repo.git

Create a new local repository

$ git init

LOCAL CHANGES

/**
* Helper function: it maps the original product ID to the new product ID.
* @param string $originId
* @return int
*/
function getProductIdOld($originId)
{
$ids = [
'OOD012' => 4225,
'OOD011' => 4001,
{
"plugins": [
"worker",
"wordpress-seo",
"gotmls",
"all-in-one-schemaorg-rich-snippets",
"seo-automatic-links",
"wordfence",
"featured-images-for-rss-feeds",
"pretty-link",
@fencermonir
fencermonir / news-search.php
Created June 15, 2020 06:00
LostEagle New Search
<?php
/**
* news Search
*/
function news_search()
{
parse_str($_POST['form'], $output);
$order = isset($_POST['order']) ? $_POST['order'] : 'ASC';
@fencermonir
fencermonir / get_first_image_of_content.php
Created May 12, 2020 20:26
Get the first image of post content.
<?php
/**
* Get the first image of post content by post_id
*/
function catch_the_first_image($post_id)
{
$first_img = '';
$content_post = get_post($post_id);
$content = $content_post->post_content;
$output = preg_match_all('/<img.+?src=[\'"]([^\'"]+)[\'"].*?>/i', $content, $matches);
@fencermonir
fencermonir / composer.json
Created March 26, 2020 11:58
Composer starter file for wp plugin.
===========================================
Comands
===========================================
go to the desire folder in comand promt
-> composer init
-> composer install
===========================================
{
@fencermonir
fencermonir / cf7_select_dynamic_value.php
Created March 21, 2020 13:34
Dynamically add product on CF7 select tag.
<?php
/**
* add product in cf7 select option
* help: https://pineco.de/dynamic-select-list-in-contact-form-7/
*/
function aggregate_dynamic_product_field_values ( $scanned_tag, $replace ) {
if ( $scanned_tag['name'] != 'aggregate-product' )
return $scanned_tag;