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
// Checks if there is any expiring members this month | |
if ( count( $expiring_members ) == 0 ) { | |
echo "No member is expiring in this month!"; | |
return; | |
} |
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
$labels_per_page = 14; | |
$no_of_pages = ceil( count( $expiring_members ) / $labels_per_page ); | |
$index = 0; | |
$template_file = dirname( MPLUS_CE ) . '/assets/template.docx'; | |
$upload_dir = wp_get_upload_dir(); | |
$save_path = $upload_dir[ 'basedir' ] . '/expiring_memberships.docx'; | |
$save_url = $upload_dir[ 'baseurl' ] . '/expiring_memberships.docx'; | |
$document = new Mplus_PHPWord_Template( $template_file ); | |
$countries = WC()->countries->get_countries(); |
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
for ( $i = 0; $i < $no_of_pages; $i++) { | |
// Adds a page to put the data in. | |
$document->add_page(); | |
// Goes through each label (for each item). | |
for ( $j = 0; $j < $labels_per_page; $j++ ) { | |
/* | |
* Some variables to be used later. | |
* The values will be put later. | |
*/ | |
$index2 = $j + 1; |
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
require_once( dirname( MPLUS_CE ) . '/vendor/PHPWord/Template.php' ); | |
class Mplus_PHPWord_Template extends PHPWord_Template | |
{ | |
private $page_xml; | |
public function __construct( $strFilename ){ | |
parent::__construct( $strFilename ); | |
$this->page_xml = file_get_contents(dirname( MPLUS_CE ) . '/assets/page.txt'); | |
} |
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 | |
/** | |
* Gets Yoast SEO primary category. | |
* | |
* @param int $post_id ID of the product to get category of. | |
* @return string | |
*/ | |
public function get_primary_cat( $post_id ) { | |
$cat_name = ''; | |
if ( class_exists( 'WPSEO_Primary_Term' ) ) { |
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
#!/bin/bash | |
sassc -t expanded style.scss > style.css | |
sed -i -e 's/ / /g' style.css | |
# Save as .sh file on the same directory as the css. e.g. generate.sh | |
# chmod +x generate.sh | |
# ./generate.sh | |
# This method requires no tools, no hacks, no code edits etc. Easy and simple! |
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
#!/bin/bash | |
# Arch Linux and Debian has different names for Apache service. | |
# Some people may like Mysql over Mariadb, which has different service | |
# names. | |
# This script detects which service is available and starts or stops it. | |
# So it basically lets you start or stop the server in one command. | |
# This is great for maintaining one piece of code that can be used on | |
# different distros. | |
# To use it, place the code below on your ~/.bashrc or if you have it, |
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
#!/bin/bash | |
# This bash script (1) runs a python script if not already running | |
# or (2) kills the script if already running. Easily put, it inverts | |
# the running state of the script. Great for toggling GUI scripts. | |
# Run chmod +x python-invert.sh and then run this with the python | |
# script path as parameter: ./python-invert.sh path/to/script.py | |
script_name=${1} |
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
" This code sets shortcuts for close buffer and save. | |
" They both work to let you know when a file has unsaved changes | |
" and offers you to give it a filename. We take this granted on | |
" modern text editors, but VIM does not have it by default. | |
" Tested in NeoVim, but should work with VIM as well. | |
" Put this on your ~/.vimrc for VIM and ~/.config/nvim/init.vim for | |
" neovim. | |
" Remaps 2 keyboard shortcuts | |
" Ctrl+W: for closing the buffer (and ask for confirmation, filename etc.) | |
" Ctrl+S: save (and ask for filename if not already saved |
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
<?xml version="1.0"?> | |
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | |
<fontconfig> | |
<!-- | |
Config file to solve the problem that weird font shows when Bangla/Bengali | |
text appears within Monospace text. I had a debian install which was showing | |
Mitra Mono in place of Bengali text which was not great to look at. It will | |
show the Bengali text in SolaimanLipi font when Monospace text is shown. |