Help with SQL commands to interact with a MySQL database
- Mac /usr/local/mysql/bin
- Windows /Program Files/MySQL/MySQL version/bin
- Xampp /xampp/mysql/bin
use Drupal\node\Entity\Node; | |
use Drupal\taxonomy\Entity\Term; | |
use Drupal\views\ViewExecutable; | |
use Drupal\views\Views; | |
use Drupal\Core\Render; | |
$nid = 1; | |
$entity_type = 'node'; | |
$view_mode = 'teaser'; | |
$builder = \Drupal::service('entity_type.manager')->getViewBuilder($entity_type); | |
$storage = \Drupal::service('entity.manager')->getStorage($entity_type); |
jQuery(function($) { | |
/** | |
* catch AJAX complete events, to catch wordpress actions | |
* @param {jQuery.Event} event | |
* @param {jqXHR} xhr XmlHttpRequest object | |
* @param {Object} settings options for the AJAX request | |
*/ | |
$(document).ajaxComplete(function(event, xhr, settings) { | |
// Specify the AJAX action after which you want to execute your JS | |
if ("data" in settings && settings.data.indexOf("action=your_ajax_action") != -1) { |
<?php | |
function return_with_k_in_number( $number ) { | |
if( $number>1000 ) { | |
$x = round($number); | |
$x_number_format = number_format($x); | |
$x_array = explode(',', $x_number_format); | |
$x_parts = array('K', 'M', 'B', 'T'); |
<?php | |
//Capture a new member signup. Only ever triggers once for each new member. | |
//Does not trigger for exising members who have subscribed to a Membership before. | |
// | |
//The user may not be logged in when this is called | |
//as it is triggered when a user is added over the REST API, | |
//and also when a user is added from the dashboard (MemberPress -> Members -> Add New) | |
function mepr_capture_new_member_signup_completed($event) { | |
$user = $event->get_data(); | |
$txn_data = json_decode($event->args); |
<?php | |
register_activation_hook( __FILE__, 'plugin_create_db' ); | |
function plugin_create_db() { | |
// Create DB Here | |
global $wpdb; | |
$charset_collate = $wpdb->get_charset_collate(); | |
$table_name = $wpdb->prefix . 'test_table'; | |
$sql = "CREATE TABLE $table_name ( | |
id mediumint(9) NOT NULL AUTO_INCREMENT, |
<?php | |
function tl_save_error() { | |
update_option( 'plugin_error', ob_get_contents() ); | |
} | |
add_action( 'activated_plugin', 'tl_save_error' ); |
<?php | |
function cpm_cc_customize_register( $wp_customize ) { | |
$wp_customize->add_panel('cpm_cc_option_panel', array( | |
'capability' => 'edit_theme_options', | |
'theme_supports' => '', | |
'title' => __('CC Options'), | |
'description' => __('Panel to update theme options'), // Include html tags such as <p>. | |
'priority' => 10 // Mixed with top-level-section hierarchy. | |
) |
<?php | |
if(class_exists('MeprUtils')) { | |
$user = MeprUtils::get_currentuserinfo(); | |
if($user !== false && isset($user->ID)) { | |
//Returns an array of Membership ID's that the current user is active on | |
//Can also use 'products' or 'transactions' as the argument type | |
$active_prodcuts = $user->active_product_subscriptions('ids'); | |
if(!empty($active_prodcuts)) { |
<?php | |
global $wpdb; | |
$result = $wpdb->get_results("SELECT * FROM `$table` WHERE `user_id` = $user_id $extend AND MONTH(created) = MONTH(CURRENT_DATE()) | |
AND YEAR(created) = YEAR(CURRENT_DATE()) order by id DESC" ); | |
//created being a nave of a date column 2019-04-10 19:03:43 |