Skip to content

Instantly share code, notes, and snippets.

View gwin's full-sized avatar

Greg Winiarski gwin

View GitHub Profile
@gwin
gwin / wpjb-job-is-bookmarked.php
Last active August 29, 2015 14:17
Check if job is bookmarked by current user.
<?php
/**
* Check if $job is bookmarked by currently logged in user
*
* @var $job Wpjb_Model_Job
* @return boolean True if job is bookmarked, false otherwise
**/
function my_wpjb_job_is_bookmarked(Wpjb_Model_Job $job) {
$id = get_current_user_id();
@gwin
gwin / callback.php
Created March 17, 2015 09:12
Form Callback Function
<?php
/**
* Example callback function for filling <select> fields
*
* @retuen array
**/
function my_callback_function() {
return array(
array("key"=> "1", "value"=>"One", "description"=>"One"),
array("key"=> "2", "value"=>"Two", "description"=>"Two"),
@gwin
gwin / wpjb-login-customize-1.php
Last active August 29, 2015 14:17
Customize [wpjb_login] shortcode.
<?php
// You can place this code in your theme functions.php file
// or create new plugin and put the code there.
add_filter("wpjb_shortcode_login", "my_wpjb_shortcode_login");
function my_wpjb_shortcode_login(Daq_View $view) {
// Text on login button
$view->submit = "Login Me!" ;
@gwin
gwin / wpadverts-add-currency.php
Created March 29, 2015 09:08
Add new currency
<?php
// The code below you can paste in your theme functions.php or create
// new plugin and paste the code there.
add_filter("adverts_currency_list", "add_adverts_currency");
/**
* Add new currency to the list
*
@gwin
gwin / wpjb-job-already-applied-to.php
Created March 31, 2015 08:48
Check if current user already applied to current job
<?php
/**
* Check if current user already applied to $job
*
* @var $job Wpjb_Model_Job
* @return boolean True if current user already applied to $job
**/
function my_wpjb_job_already_applied_to(Wpjb_Model_Job $job) {
$id = get_current_user_id();
@gwin
gwin / wpjb-job-is-bookmarked.php
Last active August 29, 2015 14:20
Checks if current job is already bookmarked
<?php
/**
* Check if current user already bookmarked $job
*
* @var $job Wpjb_Model_Job
* @return boolean True if current user already bookmarked $job
**/
function my_wpjb_job_is_bookmarked(Wpjb_Model_Job $job) {
$id = get_current_user_id();
@gwin
gwin / wphd-action-new-message-tpl.php
Created May 28, 2015 15:39
Action my_wphd_new_message Basci Example
<?php
// Register action, notice fourth argument (3)
// it allows to pass 3 params to callback function
add_action("wphd_new_message", "my_wphd_new_message", 10, 3);
/**
* @var $thread Wphd_Model_Thread Current thread
* @var $message Wphd_Model_Message Current message
* @var $context string One of: "admin", "email-import", "submit-ticket", "tickets"
@gwin
gwin / wpadverts-custom-slugs.php
Last active August 29, 2015 14:22
Customize Adverts Custom Post Type and Taxonomy
<?php
/*
* Plugin Name: Customize Adverts slugs.
* Plugin URI: http://wpadverts.com/
* Description: This code snippet/plugin explains how to customize Adverts slugs.
* Author: Greg Winiarski
*
* IMPORTANT NOTE !!!
* In order to use this code either: download this file, then upload it to your wp-content/plugins/ directory
* and activate from wp-admin / Plugins panel (recommended) or copy whole code and upload it to your theme
@gwin
gwin / wpadverts-custom-fields-api.php
Created June 7, 2015 15:57
WORK IN PROGRESS Explains Adverts Forms API
<?php
/**
* Plugin Name: [Adverts] Custom Fields API
* Version: 1.0
* Author: Greg Winiarski
* Description: This plugin explains how to create custom fields for Add Advert form.
*/
add_filter( "adverts_form_load", "my_adverts_form_load" );
@gwin
gwin / wpadverts-enable-comments.php
Created August 31, 2015 07:16
Enable comments in Adverts
<?php
add_action("adverts_post_type", "enable_adverts_comments");
add_action("adverts_insert_post", "enable_adverts_comments_check");
add_action("adverts_update_post", "enable_adverts_comments_check");
function enable_adverts_comments( $args ) {
$args["supports"][] = "comments";
return $args;