Skip to content

Instantly share code, notes, and snippets.

View digisavvy's full-sized avatar

Alex Vasquez digisavvy

View GitHub Profile
<?php
/**
* This command registers a new WP CLI command and is intended to be run from the command line on a site that supports WP CLI.
* The command updates users' Meta Custom Field value—this can be adapted for any custom fields.
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'upt set-profile-activation', function() {
import pandas as pd
import sys
def debug_segmentation():
try:
# Read the CSV file
print("Attempting to read CSV file...")
df = pd.read_csv('analysis.csv')
print(f"\nInitial data check:")
// Start of Selection
// Initialize the arguments for the WP query to fetch various post types
$args = array(
'post_type' => ['post', 'session', 'resource', 'video'], // Define post types to query
'posts_per_page' => -1, // Set to '-1' to fetch all posts. Replace with a specific number if needed
'order' => 'DESC', // Order by descending to get the most recent or viewed first
// You can add more arguments here as per your query requirements
);
// Retrieve the most viewed posts using a function provided by the Post Views Counter plugin
<?php
/**
* Removes specified nodes from the WordPress admin bar.
*
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function remove_from_admin_bar( $wp_admin_bar ) {
// Conditional check to limit removal to non-admin area pages
if ( ! is_admin() ) {
// Remove 'comments' and 'editor_mode' nodes from the admin bar
/* File: automatic.css - Version: 2.7.2 - Generated: 2023-11-11 07:24:44 */
:root, .color-scheme--main {
--action: #010136;
--action-hover: #01013f;
--action-ultra-light: #e6e6fe;
--action-light: #b4b4fd;
--action-medium: #0505fa;
--action-dark: #03037d;
--action-ultra-dark: #010132;
--action-comp: #373701;
<?php
/**
* Plugin Name: STT Tracking for Google Tag Manager
* Version: 1.0
* Description: Push transaction details into the GTM Data Layer.
* Author: Pablo Tocho, of DigiSavvy
* Author URI: https://digisavvy.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
add_action('wp_head', 'dgs_add_new_relic_agent');
function dgs_add_new_relic_agent() { ?>
// New Relic Agent Javascript Tag Here
<?php }
<?php
function dgs_function_with_current_time() {
// Get the current date and time based on your WordPress settings
// 'Y-m-d H:i:s' will return the date and time in 'YYYY-MM-DD HH:MM:SS' format
return current_time('Y-m-d H:i:s');
}
<?php
$video_id = get_post_meta(get_the_ID(), 'session_video_file_download', true);
if ($video_id) {
$video_url = wp_get_attachment_url($video_id);
if ($video_url) {
$shortcode = '[presto_player src="' . esc_attr($video_url) . '"]';
$player_output = do_shortcode($shortcode);
echo $player_output;
}
}
SELECT *
FROM wp_postmeta
WHERE post_id = {your_post_id}
AND post_id IN (SELECT ID FROM wp_posts WHERE post_type = '{your_posttype}');
With the above query, replace {your_post_id} and {your_posttype} with the appropriate post ID and posttype.