Skip to content

Instantly share code, notes, and snippets.

Jany Martelli Jany-M

Block or report user

Report or block Jany-M

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Jany-M
Jany-M / WP_WPML_Custom_Lang_Selector.php
Last active Aug 29, 2015
[WordPress] WPML Custom Language Selector
View WP_WPML_Custom_Lang_Selector.php
<?php
if (function_exists('icl_get_languages')) {
// Native Lang Name
function get_language_name($code=''){
global $sitepress;
$details = $sitepress->get_language_details($code);
$language_name = $details['display_name']; //english_name //display_name
return $language_name;
}
// Custom Lang Selector
@Jany-M
Jany-M / WP_Change_Author_on_Post_Update.php
Last active Aug 29, 2015
[WordPress] Update Author on post update
View WP_Change_Author_on_Post_Update.php
<?php
// Change Author on Update
function change_on_edit() {
global $post;
$id = $post->ID;
$original_author = $post-> post_author ;
$current_author = get_current_user_id();
if (!wp_is_post_revision($id)) {
remove_action('publish_post', 'change_on_edit');
@Jany-M
Jany-M / WP_Post_Pagination.php
Last active Aug 29, 2015
[WordPress] Post Internal custom Pagination
View WP_Post_Pagination.php
<?php
// Custom Post Pagination
function custom_wp_link_pages( $args = '' ) {
global $post;
// Get Post Type name
$post_type_name = ucfirst(get_post_type(get_the_ID()));
$defaults = array(
@Jany-M
Jany-M / WP_PF_custom_classes.php
Last active Aug 29, 2015
[WordPress] Print Friendly Plugin Template Add-On - Add custom classes inside nested iFrames for customization based on Post Type
View WP_PF_custom_classes.php
<?php if(is_singular('slug-of-post-type')) :
global $post;
$p_type = get_post_type(get_the_ID());
?>
<script type="text/javascript">
jQuery(document).ready(function() {
$( ".printfriendly a" ).click(function() {
$("#pf-core").load(function() {
setTimeout( function () {
//console.log( $('#pf-core').contents().find('iframe').contents().find('#pf-print-area') );
@Jany-M
Jany-M / WP_WC_auto-confirm-bookings.php
Last active Jul 12, 2018
[WordPress] [WooCommerce] [Bookings] Auto-Confirm Booking upon Order Complete
View WP_WC_auto-confirm-bookings.php
<?php
add_action( 'woocommerce_order_status_completed', 'mark_confirm_bookings', 20, 1 );
function mark_confirm_bookings( $order_id ) {
global $wpdb;
$order = new WC_Order( $order_id );
$bookings = array();
foreach ( $order->get_items() as $order_item_id => $item ) {
@Jany-M
Jany-M / WP_is_plugin_active.php
Created Aug 12, 2015
[WordPress] Check from Frontend/Theme if a plugin is active
View WP_is_plugin_active.php
<?php // Check from theme if a plugin is active - Place in functions.php or similar
if(!function_exists('plugin_is_active')) {
function plugin_is_active($plugin_folder, $plugin_file) {
if(!isset($plugin_file) || $plugin_file == '') $plugin_file = $plugin_folder;
return in_array($plugin_folder.'/'.$plugin_file.'.php', apply_filters('active_plugins', get_option('active_plugins')));
}
}
?>
@Jany-M
Jany-M / WP_IDX_language_selector.php
Created Aug 26, 2015
[WordPress] WPML custom language selector for dsIDXpress IDX plugin compatibility
View WP_IDX_language_selector.php
<?php
// Custom Lang Selector
if (function_exists('icl_get_languages')) {
// Get Native Lang Name
function get_language_name($code=''){
global $sitepress;
$details = $sitepress->get_language_details($code);
$language_name = $details['display_name']; // options are: english_name / display_name
return $language_name;
}
@Jany-M
Jany-M / WP_merge_multiple_queries.php
Last active Sep 7, 2017
[WordPress] Merge Multiple Queries / Loops into one
View WP_merge_multiple_queries.php
<?php
// Check if values are cached, if not cache them
//delete_transient('home_slider_24h');
if(get_transient('home_slider_24h') === false) {
// RM Blog (post) query
$rm_blog_args = array(
'posts_per_page' => 1,
'cat' => 10,
@Jany-M
Jany-M / WP_remove_product_name_woocommerce_breadcrumbs.php
Created Nov 30, 2015
[WordPress] Remove Product Name & URL from WooCommerce Breadcrumbs
View WP_remove_product_name_woocommerce_breadcrumbs.php
<?php
// In your theme, make a new folder woocommerce/global/
// Add this function in a file called breadcrumbs.php, in that folder
// or integrate the existing function accordingly.
/**
* Shop breadcrumb
*
* @author WooThemes
* @package WooCommerce/Templates
@Jany-M
Jany-M / WP_query_repeater.php
Last active Feb 2, 2016
[WordPress] Repeat a Query/Loop with automatic offset, query caching through transients and cutom post type, no children, order by title
View WP_query_repeater.php
<?php
$i = 0;
$num = 30;
$offset = 30;
$cpt = 'rate-plan';
$qty = '1,2,3,4,5,6,7,8,9,10,11,12';
$times = explode(',', $qty);
foreach($times as $item) {
$i++;
You can’t perform that action at this time.