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_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_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_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_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++;
@Jany-M
Jany-M / WP_custom_column_with_cloning.php
Last active Feb 18, 2016
[WordPress] Custom column with clone button to other custom post type
View WP_custom_column_with_cloning.php
<?php
// Duplicate function
function duplicate_content(){
global $wpdb;
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'duplicate_content' == $_REQUEST['action'] ) ) ) {
wp_die('No post to duplicate has been supplied!');
}
// Get original ID
@Jany-M
Jany-M / WP_get_facebook_page_likes.php
Last active Feb 29, 2016
[WordPress] Get Facebook Page Likes and Cache them
View WP_get_facebook_page_likes.php
<?php
// Get a user Access Token (or Page Token if you're the page admin)
// https://developers.facebook.com/tools/explorer/145634995501895/
function get_fb_likes($what) {
$token = 'your_token_here';
//delete_transient('cached_fb');
if(false === ( $cached_fb_results = get_transient( 'cached_fb' ))) {
$json_url = 'https://graph.facebook.com/v2.5/'.$what.'?fields=likes&access_token='.$token;
$json = file_get_contents($json_url);
@Jany-M
Jany-M / WP_extend_duplicate_content_create_clones_and_identical_children.php
Created Apr 8, 2016
[WordPress[ Extend Duplicate Content functions to create clones and identical post children
View WP_extend_duplicate_content_create_clones_and_identical_children.php
<?php
// Requires the duplicate_content() function
// https://gist.github.com/Jany-M/ba36a0499e4fb505105e
// Add link to create a cloned CHILD of this post, to action list for post_row_actions
function duplicate_content_link( $actions, $post ) {
global $typenow;
$user_id = get_current_user_id();
$user_data = get_userdata($user_id);
You can’t perform that action at this time.