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_shortcode("current_user_id", "current_user_id"); | |
function current_user_id() { | |
$user = wp_get_current_user(); | |
if( isset( $user->ID ) ) { | |
return $user->ID; | |
} else { | |
return "0"; |
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_filter( "adverts_form_load", "my_adverts_form_load" ); | |
function my_adverts_form_load( $form ) { | |
if( $form['name'] != "advert" ) { | |
return $form; | |
} | |
foreach( $form["field"] as $key => $field ) { | |
if( in_array($field["name"], array("adverts_price", "adverts_location", "adverts_phone") ) ) { |
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
function wpadverts_mal_save_advert( $post_ID, $post, $update ) { | |
if( !isset( $_POST ) || empty( $_POST ) ) { | |
return; | |
} | |
include_once ADVERTS_PATH . '/includes/class-form.php'; | |
$form = new Adverts_Form; | |
$form->load( Adverts::instance()->get( "form_mal" ) ); |
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 | |
// Assign a filter | |
add_filter( 'wphd_file_upload', 'my_wphd_file_upload' ); | |
/** | |
* Check if uploaded file extension is valid. | |
* | |
* This function is executed using 'wphd_file_upload' filter, | |
* it stops file upload using die() if incorrect file type is sent |
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_filter("wpjb_form_init_alert", "my_form_init_alert"); | |
function my_form_init_alert($form) { | |
$e = $form->create("frequency", "select"); | |
$e->addOption("1", "1", "Daily"); | |
$e->addOption("2", "2", "Weekly"); | |
$e->addClass("wpjb-widget-alert-frequency"); | |
$form->addElement($e, "alert"); |
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("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; |
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 | |
/** | |
* 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" ); |
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 | |
/* | |
* 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 |
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 | |
// 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" |
NewerOlder