Skip to content

Instantly share code, notes, and snippets.

@gradosevic
gradosevic / README.md
Created May 27, 2021 10:00 — forked from nichtich/README.md
How to automatically deploy from GitHub

Deploy your site with git

This gist assumes:

  • you have an online remote repository (github / bitbucket etc.)
  • you have a local git repo
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by Apache
  • the Apache user is named www-data (may be apache on other systems)
@gradosevic
gradosevic / GIT.md
Last active May 27, 2021 08:35
GIT

Ignore already added file to .gitignore

git update-index --assume-unchanged file.txt

Remember credentials

git config --global credential.helper store

@gradosevic
gradosevic / LINUX.md
Last active October 8, 2021 09:51
Linux commands
#change owner and permissions recursively
sudo chmod -R 775  /ROOT_OF_YOUR_APP/vendor/
sudo chown -R $USER:$USER /ROOT_OF_YOUR_APP/vendor/

#impersonate as www-data in command line
sudo su www-data -s /bin/sh


#Homestead box swithc PHP version
@gradosevic
gradosevic / v3_captcha.html
Last active February 8, 2020 13:57
V3 Invisible Captcha
<form>
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response" />
<script src="https://www.google.com/recaptcha/api.js?render=PUBLIC_KEY"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('PUBLIC_KEY', {action: 'homepage'}).then(function(token) {
document.getElementById('g-recaptcha-response').value = token;
});
});
@gradosevic
gradosevic / wp-setup-checklist.php
Last active March 15, 2019 18:27
WordPress Setup Checklist
<?php
//Links
//https://www.codeinwp.com/blog/secure-your-wordpress-website/
//Upload backups script
//https://olivermarshall.net/how-to-upload-a-file-to-google-drive-from-the-command-line/
/////////////////////////////
@gradosevic
gradosevic / WPSnippets.php
Last active March 9, 2019 10:17
WP Snippets
<?php
//Allow AGCA plugin access only to one person, specified by username
function agca_access_only_admin(){
if(is_admin()){
$screen = get_current_screen();
if($screen->id === 'tools_page_ag-custom-admin/plugin'){
$user = wp_get_current_user();
//Update this ////////////////////
$accessAllowedOnlyTo = 'admin';
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/bin/npm', 'i', '-g', 'npm@latest' ]
2 info using npm@3.10.10
3 info using node@v8.4.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData npm@latest
8 silly fetchNamedPackageData npm
9 silly mapToRegistry name npm
@gradosevic
gradosevic / wordpress_add_custom_post_type_column.php
Last active February 27, 2017 16:43
WordPress: custom post type column, create, link and sort by
<?php
function manage_mypostype_custom_column( $column, $post_id ) {
global $post;
switch( $column ) {
case 'category':
$terms = get_the_terms( $post_id, 'mypostype-category' );
if($terms[0]){
$theCategory = $terms[0]->name;
@gradosevic
gradosevic / wordpress_search_in_custom_fields.php
Last active July 24, 2024 18:12
WordPress: Search in ACF fields, functions.php
<?php
///////////////////////////////////
/// SUPPORT FOR SEARCHING IN ACF
///////////////////////////////////
/* Join posts and post-meta tables
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
*/
function cf_search_join( $join ) {
global $wpdb;