Skip to content

Instantly share code, notes, and snippets.

View Stiofan's full-sized avatar

Stiofan O'Connor Stiofan

  • AyeCode Ltd
  • Ireland
View GitHub Profile
@Stiofan
Stiofan / font_awesome_build.php
Last active January 18, 2019 17:39
Build Font awesome associative array
<?php
require_once( dirname( __FILE__ ) . '/wp-load.php' ); // get WP
$result = wp_remote_get( "https://fontawesome.com/cheatsheet" );
$out = $result['body'];
$start = "window.__inline_data__ = "; // start here
$end = "</script>";
$startsAt = strpos( $out, $start ) + strlen( $start );
$endsAt = strpos( $out, $end, $startsAt );
@Stiofan
Stiofan / github-labels.js
Last active June 22, 2018 10:40
GitHub Labels
[
{
"name": "Priority: Critical",
"color": "ff2222"
},
{
"name": "Priority: High",
"color": "FF7922"
},
{
@Stiofan
Stiofan / newspaper.php
Last active September 30, 2017 13:50
Newspaper compat settings
{"Newspaper_custom":{"geodir_wrapper_open_id":"","geodir_wrapper_open_class":"","geodir_wrapper_open_replace":"<div class='td-main-content-wrap td-container-wrap'> <div class='td-container '>","geodir_wrapper_close_replace":"<\/div><\/div>","geodir_wrapper_content_open_id":"","geodir_wrapper_content_open_class":"","geodir_wrapper_content_open_replace":"<div class='td-pb-row'><div class='td-pb-span8 td-main-content' role='main'>","geodir_wrapper_content_close_replace":"","geodir_article_open_id":"","geodir_article_open_class":"","geodir_article_open_replace":"","geodir_article_close_replace":"","geodir_sidebar_right_open_id":"","geodir_sidebar_right_open_class":"","geodir_sidebar_right_open_replace":"<div class='td-pb-span4 td-main-sidebar' role='complementary'>","geodir_sidebar_right_close_replace":"<\/div><\/div>","geodir_sidebar_left_open_id":"","geodir_sidebar_left_open_class":"","geodir_sidebar_left_open_replace":"<div class='td-pb-span4 td-main-sidebar' role='complementary'>","geodir_sidebar_left_close_r
@Stiofan
Stiofan / test_sessions.php
Created July 11, 2017 09:59
Test Sessions
<?php
// Set error reporting to display all errors and notices
error_reporting(E_ALL);
// Start a session
session_start();
// Check for the existence of a known session variable
if (isset($_SESSION['test_value'])) {
_e('Test value (should increase by 1 on each page refresh): '); echo $_SESSION['test_value'];
$_SESSION['test_value']++;
} else {
@Stiofan
Stiofan / allow_comments.php
Last active April 15, 2021 16:31
Custom field to enable or disable comments
<?php // <-- you probably dont need this line
add_action('geodir_after_save_listing','_my_update_comment_settings_on_save',10,2);
function _my_update_comment_settings_on_save($last_post_id, $request_info){
global $wpdb;
if(isset($request_info['geodir_allow_comments']) && $request_info['geodir_allow_comments']=='1'){
$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'open' WHERE ID = %d", $last_post_id));
}elseif(isset($request_info['geodir_allow_comments']) && $request_info['geodir_allow_comments']=='0'){
$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'closed' WHERE ID = %d", $last_post_id));
@Stiofan
Stiofan / edd-un.php
Created May 30, 2017 14:07
EDD Upgrade Notice
<?php
/**
* @wordpress-plugin
* Plugin Name: EDD Upgrade Notice
* Plugin URI: http://ayecode.io/
* Description: Add upgrade notice support to EDD Software Licencing.
* Version: 1.0.0
* Author: Stiofan O'Connor
* Author URI: http://ayecode.io/
* License: GPL-2.0+
@Stiofan
Stiofan / wp-easy-updates.php
Last active April 28, 2017 15:02
WP Easy Updates - required notification
<?php // <- You probably don't need this line
/**
* Show WP Easy Updates required admin notification.
*/
if(is_admin()){
if (!function_exists('ayecode_show_update_plugin_requirement')) {//only load the update file if needed
function ayecode_show_update_plugin_requirement() {
if ( !defined( 'WP_EASY_UPDATES_ACTIVE' ) ) {
?>
@Stiofan
Stiofan / flatsom.json
Created April 1, 2017 15:28
Compat: Flatsom
{"Flatsome_custom":{"geodir_wrapper_open_id":"","geodir_wrapper_open_class":"","geodir_wrapper_open_replace":"<div class=\"page-wrapper page-right-sidebar\"><div class=\"row\">","geodir_wrapper_close_replace":"<\/div><\/div>","geodir_wrapper_content_open_id":"","geodir_wrapper_content_open_class":"","geodir_wrapper_content_open_replace":"<div id=\"content\" class=\"large-9 left col col-divided\" role=\"main\"><div class=\"page-inner\">","geodir_wrapper_content_close_replace":"<\/div><\/div>","geodir_article_open_id":"","geodir_article_open_class":"","geodir_article_open_replace":"","geodir_article_close_replace":"","geodir_sidebar_right_open_id":"","geodir_sidebar_right_open_class":"","geodir_sidebar_right_open_replace":"<div class=\"large-3 col\"><div id=\"secondary\" class=\"widget-area \" role=\"complementary\">","geodir_sidebar_right_close_replace":"<\/div><\/div>","geodir_sidebar_left_open_id":"","geodir_sidebar_left_open_class":"","geodir_sidebar_left_open_replace":"<div class=\"large-3 col\"><div id=\"
@Stiofan
Stiofan / custom_dashboard_link.php
Created April 1, 2017 12:12
Add link to the dashboard widget
@Stiofan
Stiofan / associations.php
Last active April 1, 2017 12:26
Associations custom field with images and links
<?php
// replace 'associations' with your html var
add_filter('geodir_custom_field_output_multiselect_var_geodir_associations','_my_association_outputs',10,3);
function _my_association_outputs($html,$location,$cf){
// check we have the post value
global $post;
if (!empty($post->{$cf['htmlvar_name']})):