Skip to content

Instantly share code, notes, and snippets.

View OksanaRomaniv's full-sized avatar

Oksana Romaniv OksanaRomaniv

  • Kalush, Ukraine
View GitHub Profile
@RadGH
RadGH / get-video-oembed-wordpress.php
Last active October 3, 2022 01:03
Get oEmbed data using WordPress oEmbed API, specifically for Video iframe
<?php
// Example 1) Using a function. Returns an array.
function radgh_get_video_data( $url, $width = null, $height = null ) {
if ( function_exists('_wp_oembed_get_object') ) {
require_once( ABSPATH . WPINC . '/class-oembed.php' );
}
$args = array();
if ( $width ) $args['width'] = $width;
if ( $height ) $args['height'] = $height;
@kellenmace
kellenmace / get-file-type-url-remote-file-wordpress.php
Created September 9, 2016 18:07
Get File Type by URL for a Remote File in WordPress
<?php
/**
* Get the file mime type for a file by its URL.
*
* @param $url The URL to the file.
* @return The file mime type or empty string on failure.
*/
function km_get_file_type_by_url( $url ) {
@esamattis
esamattis / .gitignore
Created September 7, 2016 10:42 — forked from salcode/.gitignore
.gitignore file for WordPress - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
/**
* AJAX Load More
* @link http://www.billerickson.net/infinite-scroll-in-wordpress
*/
function be_ajax_load_more() {
$args = isset( $_POST['query'] ) ? array_map( 'esc_attr', $_POST['query'] ) : array();
$args['post_type'] = isset( $args['post_type'] ) ? esc_attr( $args['post_type'] ) : 'post';
$args['paged'] = esc_attr( $_POST['page'] );
$args['post_status'] = 'publish';
@kontikidigital
kontikidigital / functions.php
Last active January 14, 2021 09:42
WooCommerce: Change Select Options Button Text for variable products
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
* custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->get_type();
switch ( $product_type ) {
@barbietunnie
barbietunnie / sanitize-filename.js
Created March 12, 2016 07:24
Sanitize a string for use as a filename
/**
* Extracted from node-sanitize (https://github.com/parshap/node-sanitize-filename/blob/master/index.js)
*
* Replaces characters in strings that are illegal/unsafe for filenames.
* Unsafe characters are either removed or replaced by a substitute set
* in the optional `options` object.
*
* Illegal Characters on Various Operating Systems
* / ? < > \ : * | "
* https://kb.acronis.com/content/39790
@wpscholar
wpscholar / array-insert-after.php
Created November 7, 2015 13:04
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@mjn666
mjn666 / gist:51dbc5aae0620e8b71f9
Created September 15, 2015 00:09
How to pre-select a choice/option in Gravity Forms using a dynamic field
/**
* Pre Select a dropdown choice/option in Gravity Forms
*
* Create a dynamic list of dropdown choices from a custom post type
* Based on the current page, pre-select a choice in the drop down
*
* @var howto_dynamic_field = the dynamic field set in Gravity Forms on the field group under the Advanced tab
* @var howto_post_type = Your custom post type you are listing in the drop down
*
*/
@renventura
renventura / genesis-add-theme-options.php
Last active August 25, 2020 21:49
Add metabox to Genesis theme options
<?php //* Mind this opening PHP tag
/**
* Register custom Genesis theme settings
* The new setting will store the user's license key
*
* @param array $defaults Default theme settings
* @return array New default theme settings
*/
add_filter( 'genesis_theme_settings_defaults', 'prefix_add_genesis_theme_settings' );
@yaronguez
yaronguez / ACF Country List
Created February 17, 2015 01:37
Country list formatted for Advanced Custom Fields select dropdown
afghanistan : Afghanistan
albania : Albania
algeria : Algeria
american_samoa : American Samoa
andorra : Andorra
angola : Angola
anguilla : Anguilla
antigua_and_barbuda : Antigua and Barbuda
argentina : Argentina
armenia : Armenia