Skip to content

Instantly share code, notes, and snippets.

@vineettalwar
vineettalwar / set-php-default-version.sh
Created April 16, 2024 10:46
Set your php default version
// Change server php default version:
sudo update-alternatives --set php /usr/bin/php8.1
@vineettalwar
vineettalwar / wp-cli-snippets.sh
Last active April 16, 2024 10:56
WP CLI Useful commands
//Delete all blog comments which are marked as pending
wp comment delete $(wp comment list --status=hold --format=ids) --force
// Get comments from specific post ID:
wp comment list --post_id={POST_ID} --fields=ID,comment_author
// Get comments form specifc post from specific comment status
wp comment list --post_id={POST_ID} --status=hold --fields=ID,comment_author
@vineettalwar
vineettalwar / youirls-index.php
Created June 29, 2020 07:54
Index.php for yourls
<?php
//X-robots header
header("X-Robots-Tag: noindex, nofollow", true);
//fallback url
header('Location: https://example.com');
@vineettalwar
vineettalwar / elasticsearch-aws-policy.txt
Created November 23, 2019 03:21
Elastic Search AWS Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "es:*",
"Resource": "arn:aws:es:<region>:<account_id>:domain/<elasticsearch_domain/*",
mkdir /var/run/mysqld/
chown mysql: /var/run/mysqld/
mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --socket=/var/run/mysqld/mysqld.sock
@vineettalwar
vineettalwar / is_plugin_active_by_textdomain.php
Last active October 14, 2019 21:16
Check if plugin is active based on text domain
/**
* Check if plugin is active based on text domain
* Pass text domain to function, will return if plugin is active
*
* @param $plugin_text_domain
* @return bool
*/
function vt_is_plugin_active_by_textdomain( $plugin_text_domain ) {
$activated_plugins = [];
$active_plugins_option = get_option( 'active_plugins' );
@vineettalwar
vineettalwar / notifications.txt
Created April 12, 2019 21:35
yoast notifications on user meta
Array
(
[0] => Array
(
[0] => Array
(
[message] => We've noticed you've been using Yoast SEO for some time now; we hope you love it! We'd be thrilled if you could give us a 5 stars rating on WordPress.org!
If you are experiencing issues, please file a bug report and we'll do our best to help you out.
<?php
/*
Title: Grouped Post
Method: post
Message: Grouped Post Created
Logged in: true
*/
piklist( 'field', array(
'type' => 'hidden'
@vineettalwar
vineettalwar / player.js
Last active March 12, 2019 07:55
player on ended event
// event on play
player.$node.on('play', function(e){
updateDisplay();
//stop play other media
$('.app-body video, .app-body audio').each(function() {
$(this)[0].pause();
});
});
@vineettalwar
vineettalwar / Ajax-back-and-forth.php
Last active March 12, 2019 07:48
Ajax back and forth
<?php
class FF_Track {
public function __construct {
add_action( 'wp_ajax_nopriv_ajax_music', array($this, 'ajax_music') );
add_action( 'wp_ajax_ajax_music', array($this, 'ajax_music') );
add_action( 'wp_ajax_nopriv_ajax_next_music', array($this, 'ajax_next_music') );
add_action( 'wp_ajax_ajax_next_music', array($this, 'ajax_next_music') );
}