Skip to content

Instantly share code, notes, and snippets.

View hchouhan's full-sized avatar
💡
Thinking

Harish Chouhan hchouhan

💡
Thinking
View GitHub Profile
@pbrocks
pbrocks / install-phpcs-with-homebrew.md
Last active December 22, 2023 08:16
Install phpcs with Homebrew

Install phpcs with Homebrew

To set up php linting, you’ll want to install this PHP CodeSniffer repo and configure with this WordPress Coding Standards repo: . There are a number of ways to do this, whether direct download, Composer, Homebrew, Pear, etc. The following is what works for me on MacOS using Homebrew:

In a terminal window on your Mac, start by updating your Homebrew.

brew doctor

Then install the Code Sniffer:

function rp4wp_force_same_category( $sql, $post_id, $post_type ) {
global $wpdb;
if ( 'post' !== $post_type ) {
return $sql;
}
$sql_replace = "
INNER JOIN " . $wpdb->term_relationships . " ON (R.`post_id` = " . $wpdb->term_relationships . ".object_id)
INNER JOIN " . $wpdb->term_taxonomy . " ON (" . $wpdb->term_relationships . ".term_taxonomy_id = " . $wpdb->term_taxonomy . ".term_taxonomy_id)
@ErisDS
ErisDS / README.md
Last active January 14, 2023 15:26
Deployment tools for Ghost themes

Gulp tools to deploy a Ghost theme

To set it up:

  • copy gulp-config.json.example to gulp-config.json
  • enter the blog admin url, no trailing slash, e.g. https://myblog.ghost.io
  • grab the client secret for the frontend from the source of any page of the blog
  • enter the email address & password you use to login to the blog (must be administrator-level)

To deploy:

.wpcm-vehicle-listings .wpcm-vehicle-results-wrapper .wpcm-vehicle-results li.wpcm-listings-item a .wpcm-listings-item-image-wrapper {
width: 350px !important;
height: 350px !important;
}
.wpcm-vehicle-listings .wpcm-vehicle-results-wrapper .wpcm-vehicle-results li.wpcm-listings-item a .wpcm-listings-item-description {
padding-left: 350px !important;
}
.wpcm-vehicle-listings .wpcm-vehicle-results-wrapper .wpcm-vehicle-results li.wpcm-listings-item a {
@ErisDS
ErisDS / setup.md
Last active April 13, 2019 09:58
Setup steps for installing Ghost on a fresh Ubuntu 16.04 server

Variables:

<server_ip> - ip of the server the blog is being installed on - name for the server e.g. "myblog" - domain name e.g. "myblog.mycompany.com" <ghost_mysql_pw> - a password for a ghost user in mysql <ssl_email> - an email address for letsencrypt

Steps to get from Ubuntu 16.04 fresh install to Ghost

Largely based on the following:

@angelcosta
angelcosta / content-download-email.php
Last active May 10, 2021 16:46
Download Monitor - Send as download as attachment template
<?php
/**
* Send download to user's email
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
/*$versions = $dlm_download->get_file_versions();
reset($versions);
$version = key($versions);
function dlm_csv_export_custom_meta( $data ) {
$data[] = 'my_custom_download_meta_field';
$data[] = 'my_custom_download_meta_field_2';
return $data;
}
add_filter( 'dlm_ce_extra_fields_download_meta', 'dlm_csv_export_custom_meta' );
<script>
var dlm_has_access = 1;
<?php if ( ! apply_filters( 'dlm_can_download', true, $download, $version ) ) : ?>
dlm_has_access = 0;
<?php endif ?>
_gscq = window._gscq || [];
_gscq.push(['targeting','dlm_has_access', dlm_has_access]);
</script>
function dlm_pa_category_no_children( $query_args ) {
$query_args['tax_query'][0]['include_children'] = false;
return $query_args;
}
add_filter( 'dlm_page_addon_category_query_args', 'dlm_pa_category_no_children' );
function mc4wp_dlm_dynamic_url( $url, $form ) {
if ( isset( $_POST['mc4wp_dlm_download_id'] ) && ! empty( $_POST['mc4wp_dlm_download_id'] ) ) {
$download = new DLM_Download( absint( $_POST['mc4wp_dlm_download_id'] ) );
$url = $download->get_the_download_link();
}
return $url;
}