Skip to content

Instantly share code, notes, and snippets.

View worduoso's full-sized avatar

Andrei Filonov worduoso

View GitHub Profile
@worduoso
worduoso / wr-google-maps.php
Last active July 16, 2018 03:21
WR-Pagebuilder Google Map fix
function worduoso_assets() {
wp_deregister_script('wr-pb-googlemap-js');
wp_register_script( 'wr-pb-googlemap-js', 'https://maps.googleapis.com/maps/api/js?v=3.exp&key=API_KEY_FROM_GOOGLE', null, null, true );
}
add_action('wp_enqueue_scripts', 'worduoso_assets', 10000);
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'your_database_name');
/** MySQL database username */
define('DB_USER', 'your_database_username');
/** MySQL database password */
define('DB_PASSWORD', 'your_database_password');
@worduoso
worduoso / my-plugin.php
Created May 18, 2018 23:06
Custom post type added in plugin
<?php
/*
Plugin Name: My Custom Post Type
Description: Minimal code to add custom post type in a plugin
Version: 0.01
Author: Myself
*/
add_action( 'init', 'my_custom_plugin_create_post_type' );
<?php
/*
* Add custom widget to display ASIDE posts
*/
class Worduoso_Aside_Widget extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_aside_posts', 'description' => __('Displays Latest Aside Posts'));
$this->WP_Widget('widget_worduoso_aside', "Aside Posts", $widget_ops);
@worduoso
worduoso / remove-asides.php
Last active April 16, 2018 22:35
Display asides in the sidebar
<?php
/*
* exclude ASIDE format posts from the main loop
*/
function worduoso_exclude_asides( $query ) {
if ( !is_admin() && $query->is_main_query() ) {
$query->tax_query->queries[] = array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-aside',
<?php
// The Query
$args = array(
'post_type' => 'post',
'posts_per_page' => 1,
);
$the_query = new WP_Query( $args );
// now get random number and pull one random page (with one post per page)
@worduoso
worduoso / custom-login-labels.php
Created March 16, 2018 01:46
Customize WordPress login labels
function gettext_filter($translation, $orig, $domain) {
switch($orig) {
case 'Username or Email Address':
$translation = "Student ID";
break;
case 'Username':
$translation = "Student ID";
break;
case 'Password':
$translation = 'Access Code';
@worduoso
worduoso / functions.php
Created July 18, 2017 23:26
Add custom options to WordPress website to use (display) in your theme
/**
* add custom section to theme customizer (Appearance -> Customize)
*/
function worduoso_customize_register($wp_customize) {
// add section to customizer
$wp_customize->add_section( 'worduoso' , array(
'title' => __('My Custom Section','worduoso'),
'priority' => 10,
));
@worduoso
worduoso / functions.php
Created July 18, 2017 22:57
Show empty categories in the WordPress menu editor when searching by keyword
add_filter('get_terms_args', 'wodruoso_terms_args', 10, 1);
function wodruoso_terms_args($args) {
if(is_admin() && isset($args["name__like"]) && !empty($args["name__like"])) {
$args["hide_empty"] = 0;
}
return $args;
}
@worduoso
worduoso / gf-editor-access.php
Last active May 22, 2017 14:48
Gravity Forms Entries access for editors
<?php
function worduoso_editor_access() {
$role = get_role( 'editor' );
$role->add_cap( 'gravityforms_view_entries' );
$role->add_cap( 'gravityforms_view_entry_notes' );
}
add_action( 'admin_init', 'worduoso_editor_access');