This file contains hidden or 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 | |
// | |
// Check the plugin dependencies | |
// | |
add_action('init', function(){ | |
// Only Check for requirements in the admin | |
if(!is_admin()){ | |
return; |
This file contains hidden or 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 | |
// Let us make sure we are on the curent site. | |
restore_current_blog(); | |
// get the image src | |
$image_url = wp_get_attachment_image_src( $_POST['featured_image'], 'full' ); | |
$image_url = $image_url[0]; | |
// Now let us switch to the Blog we like to set the featured image |
This file contains hidden or 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 | |
/** | |
* This function allows you to retrieve the wp_get_attachment_image_src() | |
* data for any post's featured image on your network. If you are running | |
* a multisite network, you can supply another blog's ID to retrieve a post's | |
* featured image data from another site on your WordPress multisite network. | |
* | |
* Does not take care of icon business (at this time). | |
* |
This file contains hidden or 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 | |
/** | |
* Check if a contributor have the needed rights to upload images and add this capabilities if needed. | |
*/ | |
add_action('init', 'buddyforms_allow_contributor_uploads'); | |
function buddyforms_allow_contributor_uploads() { | |
if ( current_user_can('contributor') && !current_user_can('upload_files') ){ | |
$contributor = get_role('contributor'); |
This file contains hidden or 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 we use to add a extra class to all BuddyForms related metaboxes. | |
*/ | |
function buddyforms_metabox_class($classes) { | |
$classes[] = 'buddyforms-metabox'; | |
return $classes; | |
} | |
/** |
This file contains hidden or 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 the Tab Content | |
// | |
add_action( 'buddyforms_settings_page_tab', 'my_buddyforms_settings_page_tab' ); | |
function my_buddyforms_settings_page_tab(){ | |
?> | |
<div class="metabox-holder"> | |
<div class="postbox"> |
This file contains hidden or 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 | |
//----------AFTER THE FORM HAS BEEN SUBMITTED---------- | |
include("PFBC/Form.php"); | |
if(!Form::isValid("<replace with unique form identifier>")) { | |
/* Validation errors have been found. We now need to redirect users back to the | |
form back so the errors can be corrected and the form can be re-submitted. | |
In case of ajax submit Form::renderAjaxErrorResponse () will build an error reply.*/ | |
if ($reqIs("AJAX")) { | |
header ("Content-type: application/json"); |
This file contains hidden or 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 | |
Form::open ("test", $values, ["ajax" => "finishCallback"]); | |
Form::hidden ("id"); | |
From::Button ("Submit"); | |
Form::close (); | |
?> | |
<script> | |
function finishCallback (data) { | |
console.log (data.status); | |
console.log (data.message); |
This file contains hidden or 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 | |
// SideBySide View | |
// Default library view type. form-horizonal bootstrap form layout. | |
Form::open ("test1", $values) | |
//Inline View | |
// form-inline bootstrap form layout. | |
Form::open ("test1", $values, "view" = "Inline") | |
// Vertical View |
This file contains hidden or 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 | |
// Generates a hidden input element | |
Form::Hidden ("id", $attributes = null); | |
//Textbox | |
Form::Textbox ("Text", "text", $attributes = null); | |
// Number | |
Form::Number("Number", "Number", $attributes = null); |