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
<!-- functions.php --> | |
<?php | |
add_action( 'wp_enqueue_scripts', 'theme_custom_style_script', 11 ); | |
function theme_custom_style_script() { | |
wp_enqueue_style( 'dynamic-css', admin_url('admin-ajax.php').'?action=dynamic_css', '', VERSION); | |
} | |
add_action('wp_ajax_dynamic_css', 'dynamic_css'); | |
add_action('wp_ajax_nopriv_dynamic_css', 'dynamic_css'); |
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 | |
function defer_parsing_of_js ( $url ) { | |
if ( FALSE === strpos( $url, '.js' ) ) return $url; | |
if ( strpos( $url, 'jquery.js' ) ) return $url; | |
return "$url' defer "; | |
} | |
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 ); |
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 | |
/* | |
* | |
* Use the code at the beginning of a plugin that you want to be laoded at last | |
* | |
*/ | |
function this_plugin_last() { | |
$wp_path_to_this_file = preg_replace('/(.*)plugins\/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__); | |
$this_plugin = plugin_basename(trim($wp_path_to_this_file)); | |
$active_plugins = get_option('active_plugins'); |
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 | |
/** | |
* Protect direct access | |
*/ | |
// This line is for WordPress | |
if ( ! defined( 'ABSPATH' ) ) die( 'Sorry cowboy! This is not your place' ); | |
if( ! defined( 'SOME_RANDOM_STRING' ) ) define( 'SOME_RANDOM_STRING', 'ABHgtu^77y&6tgJy' ); |
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 | |
// Assuming one phone field in a form | |
add_filter( 'forminator_custom_form_submit_errors', 'check_form_data', 99, 3 ); | |
function check_form_data( $submit_errors, $form_id, $field_data_array ) { | |
$valid = false; | |
foreach( $field_data_array as $val ) { | |
if( $val['name'] == 'phone-1' ) { | |
$phone = $val['value']; |
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 | |
function wpms_one_blog_only($active_signup) { | |
// get the array of the current user's blogs | |
$blogs = get_blogs_of_user( get_current_user_id() ); | |
// all users may be members of blog 1 so remove it from the count, could be a "Dashboard" blog as well | |
if ($blogs["1"]) unset($blogs["1"]); | |
//if the user still has blogs, disable signup else continue with existing active_signup rules at SiteAdmin->Options | |
$n = count($blogs); | |
if(n > 0){ |
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 | |
add_filter( 'wpmu_validate_blog_signup', 'wpmu_validate_blog_signup_cb' ); | |
function wpmu_validate_blog_signup_cb( $result ) { | |
$current_site = get_current_site(); | |
if ( ! domain_exists( $result['domain'], $result['path'], $current_site->id) ) { | |
if ( username_exists( $result['blogname'] ) ) { | |
if ( ! is_object( $result['user'] ) || ( is_object($result['user']) && ( $result['user']->user_login != $blogname ) ) ) { | |
$errors = $result['errors']; | |
$errors->remove( 'blogname' ); |
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 | |
$form_id = 7; | |
$entry_meta= array( | |
'name' => 'text-1', | |
'value' => 'Text Input Value' | |
); | |
Forminator_API::add_form_entry( $form_id, $entry_meta ); |
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 | |
/* | |
Plugin Name: User Registration to Subscription (wpmu) | |
Plugin URI: http://bappi-d-great.com | |
Description: This plugin allows your users to auto subscribe when registered | |
Author: WPMU DEV | |
Version: 1.0.1 | |
Author URI: http://bappi-d-great.com | |
*/ |
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 | |
class Model { | |
protected function __construct() { | |
parent::__construct(); | |
} | |
public static function get_instance() { | |
static $Inst = null; |
NewerOlder