Skip to content

Instantly share code, notes, and snippets.

@knilkantha
knilkantha / Method One - to hide deactivate option in current plugin
Created August 25, 2020 07:07
Hide deactivation option in specific WordPress plugin
//Add this code on plugin's main file. This will hide current plugin's deactivation option
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'disable_plugin_deactivation' );
function disable_plugin_deactivation ($actions) {
unset( $actions['deactivate'] );
return $actions;
}
@codearryaas
codearryaas / wp-react-plugin-test-add-scripts.php
Last active August 8, 2020 04:25
Steps to create wp-react-plugin-test.php
<?php
/**
* Plugin Name: WP React Plugin Test
* Plugin URI: https://racase.com.np/
* Description: A test pluing to teach React on WordPress
* Version: 1.0.0
* Author: Rakesh Lawaju
* Author URI: https://racase.com.np/
* Text Domain: wp-react-plugin-test
* Domain Path: /i18n/languages/
@hardfire
hardfire / README.MD
Last active August 12, 2021 03:34
using cgroups to limit browser memory+cpu usage
  1. cgconfig.conf - that's where you create the control group /etc/
  2. cgrules.conf - that's where you add binaries to that specific control group /etc/
  3. cgconf - that's the init script i use because its not available on ubuntu. It might be available for your OS in the package manager. I took the startup script from http://askubuntu.com/questions/836469/install-cgconfig-in-ubuntu-16-04 - /etc/init.d/

Notes

Use the following steps to test what you have without the

  • cgconfigparser -l /etc/cgconfig.conf - to add/register your control group to the system
  • cgrulesengd - sends the binary-cgroup binding rules.
@jawinn
jawinn / primary_category.php
Last active December 8, 2022 21:42
Display Primary Category (Yoast's WordPress SEO)
<?php
/**
* Get the Yoast primary category from its post meta value, and displays it, with HTML markup.
* If there is no primary category set, it displays the first assigned category.
*
* @param boolean $useCatLink Whether to link the category, if it exists
* @return void
*/
function yourtheme_display_yoast_primary_category( $useCatLink = true ) {