Skip to content

Instantly share code, notes, and snippets.

View daronspence's full-sized avatar

Daron daronspence

View GitHub Profile
<?php
'location' => array(
array(
array(
'param' => 'widget',
'op' => '==',
'value' => 'pages'
),
array(
'param' => 'widget',
@daronspence
daronspence / is-plugin-installed.php
Created January 29, 2015 00:04
Is plugin installed
$installed_plugins = array();
// check if ACF is installed
if ( is_multisite() ) :
$network_plugins = get_site_option( 'active_sitewide_plugins', array() );
$site_plugins = get_option( 'active_plugins', array() );
$installed_plugins = array_merge($network_plugins, $site_plugins);
else :
@daronspence
daronspence / remove-anonymous-object.php
Last active August 29, 2015 14:14
Remove actions/filters from anonymous class instance
// All of your classes in /acf/forms/ are called anonymously
// so it's near impossible to filter them out without this jargon. :(
// example of won't work, but should
remove_filter('in_widget_form', array('acf_form_widget', 'edit_widget'), 10 );
// See http://wordpress.stackexchange.com/questions/137688/remove-actions-filters-added-via-anonymous-functions
function acfw_remove_object_filter( $tag, $class, $method = NULL, $priority = NULL ) {
$filters = $GLOBALS['wp_filter'][ $tag ];
if ( empty ( $filters ) ) {
// Line 109 from EDD_SL_Changelog_Widget.php
$changelog = apply_filters( 'edd_sl_changeloge_widget_output' , get_post_meta( $post_id, '_edd_sl_changelog', true ) );
@daronspence
daronspence / eddslcheck.php
Created March 1, 2015 04:31
EDD SL version when checking.
$edd_updater = new EDD_SL_Plugin_Updater( ACFW_STORE_URL, __FILE__, array(
'version' => ACFW_VERSION, // current version number
'license' => $license_key, // license key (used get_option above to retrieve from DB)
'item_name' => ACFW_ITEM_NAME, // name of this plugin
'author' => 'Daron Spence', // author of this plugin
'url' => home_url()
)
);
@daronspence
daronspence / eddslremoteaction.php
Created March 1, 2015 05:20
New Action for EDD SL Remote License Check
// Insert before headers are sent (line 582) in EDD_Software_Licensing.php
do_action( 'edd_sl_remote_license_check', $result, $item_name, $item_id, $url, $expires, $license_id );
@daronspence
daronspence / include_widgets.php
Last active August 29, 2015 14:16
How to include widgets through a plugin or theme files.
add_filter( 'acfw_include_widgets', 'add_include_widgets' );
function add_include_widgets(){
$acfw_widgets = array(
array(
'title' => 'Test Widget 1',
'description' => 'A widget test from functions.php',
'slug' => 'test-widget',
'id' => 'Test_Widget',
add_filter( 'acfw_dir', 'acfw_directory' );
function acfw_directory( $dir ){
// default value is /acf-widgets/
return '/acfw/';
}
add_action('init', function(){
global $wp_roles;
$roles = $wp_roles->roles;
$choices = array();
foreach ( $roles as $key => $value ){
if ( $key !== 'administrator')
continue;
add_action('wp_head', function(){
global $posts;
foreach ( $posts as $post ){
if ( strpos($post->post_content,'[acfe_form') !== false ){
echo 'Contains the shortcode<br>'; // now do acf_form_head()
}
}
});