Skip to content

Instantly share code, notes, and snippets.

View dnshulga's full-sized avatar
🌴
On vacation

Dmitry Shulga dnshulga

🌴
On vacation
  • Worldwide
View GitHub Profile
@leanda
leanda / excerpt_tinymce.php
Created October 21, 2012 09:45
WordPress: add tinymce editor to the wordpress excerpt field
function tinymce_excerpt_js(){ ?>
<script type="text/javascript">
jQuery(document).ready( tinymce_excerpt );
function tinymce_excerpt() {
jQuery("#excerpt").addClass("mceEditor");
tinyMCE.execCommand("mceAddControl", false, "excerpt");
tinyMCE.onAddEditor.add(function(mgr,ed) {
if(ed.id=="excerpt"){
ed.settings.theme_advanced_buttons2 ="";
ed.settings.theme_advanced_buttons1 = "bold,italic,underline,seperator,justifyleft,justifycenter,justifyright,separator,link,unlink,seperator,pastetext,pasteword,removeformat,seperator,undo,redo,seperator,spellchecker,";
@dmassiani
dmassiani / pagenavi html
Created April 2, 2013 07:33
Change html for wp pagenavi
######################
# Change html pagenavi for transform like bootstrap
######################
//attach our function to the wp_pagenavi filter
add_filter( 'wp_pagenavi', 'wd_pagination', 10, 2 );
//customize the PageNavi HTML before it is output
function wd_pagination($html) {
$out = '';
@ken-muturi
ken-muturi / new_gist_file.php
Created November 17, 2013 07:03
Countries array
<?php
// https://snipt.net/public/tag/php/?page=3
$countries = array(
"AF" => array("country" => "Afghanistan", "continent" => "Asia"),
"AX" => array("country" => "Åland Islands", "continent" => "Europe"),
"AL" => array("country" => "Albania", "continent" => "Europe"),
"DZ" => array("country" => "Algeria", "continent" => "Africa"),
"AS" => array("country" => "American Samoa", "continent" => "Oceania"),
@soul-wish
soul-wish / countries.html
Last active January 31, 2023 14:04
HTML Select List Of Countries (english and russian versions, sorted by alphabet)
<select name="countries">
<option value="United States">United States</option>
<option value="United Kingdom">United Kingdom</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
@ctlcltd
ctlcltd / wordpress_low-quality-image-placeholders_lqip.md
Last active June 22, 2023 20:08
How to easily generate low quality image placeholders (lqip) in WordPress

How to easily generate low quality image placeholders (lqip) in WordPress

I have made this function using the WP_Image_Editor class and I have filtered through the "wp_generate_attachment_metadata" hook. You can modify the "theme" namespace into function names with your theme name or in anyway you like.

Applying the filter directly to wp_generate_attachment_metadata the image placeholders are auto added into WordPress metadata, so when your add/modify/delete an image (or regenerate it via a plugin), it accomplishes to modify also to the image placeholders.

The use of the native theme support can prevent the generation of lqip or target specific image sizes to generate.

It contains an hook filter lqip_quality to modify the quality without have to modify the function.

@stormwild
stormwild / woocommerce-create-order.md
Last active November 5, 2023 01:40
WooCommerce Creating Order Programmatically

WooCommerce Creating Order Programmatically

WooCommerce Create Order

creating Woocommerce order with line_item programatically

// http://stackoverflow.com/questions/26581467/creating-woocommerce-order-with-line-item-programatically
$address = array(
            'first_name' => 'Fresher',
@loorlab
loorlab / disable_tags_WP.php
Created March 5, 2017 17:04
Disable Tags WordPress
<?php
// Disable Tags Dashboard WP
add_action('admin_menu', 'my_remove_sub_menus');
function my_remove_sub_menus() {
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag');
}
// Remove tags support from posts
function myprefix_unregister_tags() {
unregister_taxonomy_for_object_type('post_tag', 'post');
@leogopal
leogopal / youtube-id.php
Last active July 5, 2021 15:37
PHP function to get youtube ID from URL
<?php
function get_youtube_video_ID($youtube_video_url) {
/**
* Pattern matches
* http://youtu.be/ID
* http://www.youtube.com/embed/ID
* http://www.youtube.com/watch?v=ID
* http://www.youtube.com/?v=ID
* http://www.youtube.com/v/ID
* http://www.youtube.com/e/ID
@vielhuber
vielhuber / functions.php
Created October 17, 2017 13:28
get permalink / url by template name #wordpress
<?php
function get_page_url($template_name)
{
$pages = get_posts([
'post_type' => 'page',
'post_status' => 'publish',
'meta_query' => [
[
'key' => '_wp_page_template',
'value' => $template_name.'.php',
@slaus
slaus / menu_item_me_awake_when_you_scroll.js
Created April 12, 2018 14:01 — forked from yaroslavKas/menu_item_me_awake_when_you_scroll.js
МЕНЯЕМ АКТИВНЫЙ ПУНКТ МЕНЮ ПРИ ПРОКРУТКЕ СТРАНИЦЫ
var menu_selector = ".top-menu"; // Переменная должна содержать название класса или идентификатора, обертки нашего меню.
var menu = jQuery('#header').outerHeight();
jQuery("#mainnav li:first-child a").addClass("current");
function onScroll(){
var scroll_top = jQuery(document).scrollTop();
jQuery(menu_selector + " a").each(function(){
var hash = jQuery(this).attr("href");
var target = jQuery(hash);