Skip to content

Instantly share code, notes, and snippets.

View msn60's full-sized avatar

Mehdi Soltani msn60

View GitHub Profile
@msn60
msn60 / custom_comments.php
Created July 10, 2021 05:46 — forked from ramseyp/custom_comments.php
Different ways of customizing the WordPress comment form
<?php
// Customized the comment form fields ( not the comment text area )
add_filter('comment_form_default_fields', 'my_comment_form_args');
// Customizes the text area - you have to do this here, rather than in comment_form_default_fields
add_filter('comment_form_field_comment', 'my_comment_form_field_comment');
// Customized the comment notes above the form fields
add_filter( 'comment_form_defaults', 'my_comment_form_defaults' );
@msn60
msn60 / share-urls.md
Created July 5, 2021 13:09 — forked from apisandipas/share-urls.md
Share url's for Facebook, Twitter, Pinterest and Linkedin with just get variables

Creating share buttons with just URL's

Twitter

http://twitter.com/share?text=<TITLE>&url=<URL>

E.g. http://twitter.com/share?text=This+is+google+a+search+engine&url=https%3A%2F%2Fwww.google.com

Facebook

http://www.facebook.com/sharer.php?u=&amp;p[title]=

@msn60
msn60 / functions.php
Created June 21, 2021 11:26 — forked from RichardNesbitt/functions.php
WP Bakery Page Builder - Add URL option to make entire column clickable
<?php
/* add this to your theme's functions.php file */
/* Add option for URL to column settings */
vc_add_param("vc_column", array(
"type" => "vc_link",
"class" => "",
"heading" => "Column Link",
@msn60
msn60 / nginx.conf
Created May 15, 2021 18:27 — forked from leandromoreira/nginx.conf
nginx.conf optmized for http/2 = HTTPS TLS (ssl)
# command to generate dhparams.pen
# openssl dhparam -out /etc/nginx/conf.d/dhparams.pem 2048
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
limit_req_status 444;
limit_conn_status 503;
proxy_cache_path /var/lib/nginx/proxy levels=1:2 keys_zone=backcache:8m max_size=50m;
proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";
@msn60
msn60 / wp-secure.conf
Created March 29, 2021 08:55 — forked from ethanpil/wp-secure.conf
Wordpress Security for NginX
# wp-secure.conf
#
#
# This file includes common security considerations for wordpress using nginx.
#
# The goal is to block actions which are usually dangerous to wordpress.
# Additionally, we block direct access to PHP files and folders which should not
# be accessed directly from a browser.
#
# Also have included exceptions for plugins that are known to require this access.
@msn60
msn60 / ubuntu-hardening.md
Created March 26, 2021 05:51 — forked from lokhman/ubuntu-hardening.md
List of things for hardening Ubuntu

System Updates

http://bookofzeus.com/harden-ubuntu/initial-setup/system-updates/

Keeping the system updated is vital before starting anything on your system. This will prevent people to use known vulnerabilities to enter in your system.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get autoclean
@msn60
msn60 / wp_log_http_requests.php
Created March 23, 2021 17:30 — forked from hinnerk-a/wp_log_http_requests.php
WordPress filter hook for logging WP HTTP requests
<?php
function wp_log_http_requests( $response, $args, $url ) {
// set your log file location here
$logfile = plugin_dir_path( __FILE__ ) . '/http_requests.log';
// parse request and response body to a hash for human readable log output
$log_response = $response;
if ( isset( $args['body'] ) ) {
@msn60
msn60 / acf-disable-frontend.php
Created September 17, 2020 07:27 — forked from leepeterson/acf-disable-frontend.php
Disable ACF functions on the front-end of WordPress in order to provide a performance boost.
<?php
/**
* Plugin Name: Disable ACF on Frontend
* Description: Disable ACF functions on the front-end of WordPress in order to provide a performance boost.
* Version: 2.0
* Author: Lee Peterson
* Author URI: http://www.leepeterson.me
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
@msn60
msn60 / cmb2-custom-field-example.php
Created August 24, 2020 16:56
Repeatable Custom CMB2 Field
function cmb2_render_book_field_callback( $field, $value, $object_id, $object_type, $field_type_object ) {
// make sure we specify each part of the value we need.
$value = wp_parse_args($value, array(
'book-photo' => '',
'book-name' => '',
'book-price' => '',
'book-id' => '',
));
?>
@msn60
msn60 / cmb2-repeater-demo-display-data.php
Created August 24, 2020 16:55 — forked from damiencarbery/cmb2-repeater-demo-display-data.php
CMB2 Repeater Demo - a simple example
<?php
add_filter( 'the_content', 'crd_append_post_links' );
function crd_append_post_links( $content ) {
if ( is_page() ) {
$post_links_data = get_post_meta( get_the_ID() );
if ( isset( $post_links_data[ 'blog_group' ][ 0 ] ) ) {
$blog_list = maybe_unserialize( $post_links_data[ 'blog_group' ][ 0 ] );
$posts_list = '<ul>';
foreach ( $blog_list as $post_info ) {