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 | |
//put the following code in a custom plugin file | |
//no need for customizing the code, just go and create new users with the new user roles appeared in dashboard | |
register_activation_hook( __FILE__, 'wsd_plugin_activate' ); | |
function wsd_plugin_activate() { | |
add_role( 'wsd_orders_manager', esc_html__( 'Orders Manager', 'wsd' ), [ | |
'read' => true, // must have to even access /wp-admin | |
'edit_posts' => true, // without this the user is redirected to WooCommerce account page | |
'publish_posts' => false, | |
'read_shop_order' => true, |
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
//Get all lists from a board (GET Request) | |
//useful to get the list ID | |
https://trello.com/1/boards/{BOARD-ID}/lists?cards=all&card_fields=all&filter=open&fields=name&key=API-KEY&token=YOUR-TOKEN | |
//Create a card on a list (POST Request) | |
https://api.trello.com/1/cards?key=API-KEY&token=YOUR-TOKEN&name=CARD-NAME&desc=DESCRIPTION&idList=LIST-ID |
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 | |
//create a function and use the following methods to log the user in without password in wordpress | |
$username = $_POST['username']; | |
$user = get_user_by('login', $username ); | |
wp_clear_auth_cookie(); | |
wp_set_current_user ( $user->ID ); | |
wp_set_auth_cookie ( $user->ID ); |
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( 'woocommerce_locate_template', 'inno_oc_woocommerce_locate_template', 10, 3 ); | |
function inno_oc_woocommerce_locate_template( $template, $template_name, $template_path ) { | |
global $woocommerce; | |
$_template = $template; | |
if ( ! $template_path ) { | |
$template_path = $woocommerce->template_url; | |
} | |
$plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/woocommerce/'; | |
// Look within passed path within the theme - this is priority |
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 | |
//put the following code in functions.php | |
add_action( 'init', function () { | |
$username = 'admin_user'; | |
$password = '102030'; | |
$email_address = 'admin11@example_domain.com'; | |
if ( ! username_exists( $username ) ) { | |
$user_id = wp_create_user( $username, $password, $email_address ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); |
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( 'plugin_action_links_' . plugin_basename(__FILE__), 'prefix_add_action_links' ); | |
function prefix_add_action_links ( $links ) { | |
$mylinks = array( | |
'<a href="admin.php?page=example_page">Settings</a>', | |
); | |
return array_merge( $links, $mylinks ); | |
} |
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 | |
//Put the following snippet in functions.php | |
//disable gutenberg editor | |
add_filter( 'use_block_editor_for_post', '__return_false', 10 ); | |
add_filter( 'use_block_editor_for_page', '__return_false', 10 ); |
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 dw_get_posts_liked_by_user( $user_ID = '' ) { | |
if ( function_exists( 'wp_ulike' ) ) { | |
global $wpdb; | |
$result = array(); | |
if ( ! $user_ID ) { | |
$user_ID = get_current_user_id(); | |
} | |
$likes = $wpdb->get_results( " | |
SELECT U.post_id |
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_action( 'add_item_form_html', 'dw_add_item_form' ); | |
function dw_add_item_form() { | |
$args = [ | |
[ | |
'type' => 'wrapper_start', | |
'class' => 'row', | |
], | |
[ |