This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* REQUIRES: TwitterOAuth | |
* https://github.com/abraham/twitteroauth/tree/master/twitteroauth | |
* | |
* Download and place in a /twitteroauth/ folder in your theme/plugin. | |
*/ | |
session_start(); | |
require "twitteroauth/autoload.php"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** WP Function to show current online users | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
function ns_user_online_update(){ | |
if ( is_user_logged_in()) { | |
// get the user activity the list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** WooCommerce: Auto complete paid Orders depending on payment methods | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
add_action( 'woocommerce_thankyou', 'ns_wc_auto_complete_paid_order', 20, 1 ); | |
function ns_wc_auto_complete_paid_order( $order_id ) { | |
if ( ! $order_id ) | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Add "Note to Customer" to the PDF invoice, this code needs WooCommerce PDF Invoices & Packing Slips plugin | |
* | |
* https://www.nuno-sarmento..com | |
*/ | |
add_action( 'wpo_wcpdf_after_order_details', 'ns_add_note_to_customer_to_PDF_invoice' ); | |
function ns_add_note_to_customer_to_PDF_invoice() { | |
global $wpo_wcpdf; | |
$wpo_wcpdf->order_notes(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** WordPress, redirect WP admin URLs for all users apart for the ones declare on the users array | |
* | |
* https://www.nuno-sarmento..com | |
*/ | |
function ns_redirect_users_by_role() { | |
global $pagenow; | |
if ( ! defined( 'DOING_AJAX' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extend WordPress search to include custom fields | |
* | |
* https://www.nuno-sarmento..com | |
*/ | |
/** | |
* Join posts and postmeta tables | |
* | |
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adds a custom "Read more" link to post excerpts of custom post types. | |
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and "Read more". | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
function ns_cpt_excerpt_more( $more ) { | |
global $post; | |
$anchor_text = 'Read more'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Predefine category for new products - this function will add a category automatically when the user creates a Product | |
* | |
* https://www.nuno-sarmento..com | |
*/ | |
add_action( 'save_post', 'ns_auto_add_product_category', 50, 3 ); | |
function ns_auto_add_product_category( $post_id, $post, $update ) { | |
if ( $post->post_type != 'product') return; // Only products |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Add Admin Event Column | |
* | |
* https://www.nuno-sarmento.com | |
* | |
*/ | |
function ns_users_events_column( $cols ) { | |
$cols['user_events'] = 'Events'; | |
return $cols; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Admin user page custom column - Print User Web Visits Column Value | |
* | |
* https://www.nuno-sarmento.com | |
* | |
*/ | |
class NSLogin_Counter { | |
public function init() { | |
add_action( 'wp_login', array( $this, 'count_user_login' ), 10, 2 ); |