This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$image = new JImage('/path/to/original.jpg'); | |
$height = $image->getHeight(); | |
$width = $image->getWidth(); | |
if ($height > $width) { | |
$crop_square = $width; | |
$crop_top = ($height - $width) / 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'template_redirect', 'remove_product_from_cart' ); | |
function remove_product_from_cart() { | |
// Run only in the Cart or Checkout Page | |
if( is_cart() || is_checkout() ) { | |
// Set the product ID to remove | |
$prod_to_remove = 56; | |
// Cycle through each product in the cart | |
foreach( WC()->cart->cart_contents as $prod_in_cart ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replaces query version in registered scripts or styles with file modified time | |
* | |
* @link https://wordpress.stackexchange.com/a/346024/51130 based on | |
* | |
* @param $src | |
* | |
* @return string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gulpfile.js | |
// Initialize modules | |
const gulp = require('gulp'); | |
// Importing all the Gulp-related packages we want to use | |
const concat = require('gulp-concat'); | |
const sourcemaps = require('gulp-sourcemaps'); | |
const sass = require('gulp-sass'); | |
//const browserSync = require('browser-sync'); | |
//const server = browserSync.create(); | |
const child = require('child_process'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function renderForm ($endpoint) { | |
// get the data from the API and convert it to a PHP object | |
$formResult = file_get_contents($endpoint); | |
$formContent = json_decode($formResult); | |
$formFields = $formContent->fields; | |
// start building the DOM | |
$dom = new DOMDocument(); | |
$form = $dom->createElement('form'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"alignleft": { | |
"selector": "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img", | |
"classes": "left" | |
}, | |
"aligncenter": { | |
"selector": "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img", | |
"classes": "center" | |
}, | |
"alignright": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires jQuery of course. | |
$(document).ready(function() { | |
$('.show-comments').on('click', function(){ | |
var disqus_shortname = 'YOUR-DISQUS-USERNAME'; // Replace this value with *your* username. | |
// ajax request to load the disqus javascript | |
$.ajax({ | |
type: "GET", | |
url: "http://" + disqus_shortname + ".disqus.com/embed.js", | |
dataType: "script", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label for="demo">Demo</label> | |
<select id="demo" name="demo"> | |
<?php array_unshift($this->myExampleOptionsArray, null); ?> | |
<?php echo HTMLHelper::_('select.options', $this->myExampleOptionsArray, 'value', 'text', $this->selectedOptionValue ?? '');?> | |
</select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('_JEXEC') or die; | |
?> | |
<div class="latestnews"> | |
<ul class="list-group list-group-flush"> | |
<?php foreach ($list as $item) : $image = json_decode($item->images); ?> | |
<?php | |
// most important part | |
// context: | |
// for articles: com_content.article |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* Based on (forked from) the work by https://gist.github.com/Kostanos | |
* | |
* This revision allows the PHP file to be included/required in another PHP file and called as a function, rather than focusing on command line usage. | |
* | |
* Convert JSON file to CSV and output it. | |
* | |
* JSON should be an array of objects, dictionaries with simple data structure |
OlderNewer