'.__('Load Template', 'fusion-core').'
';
//get templates data
$templates = get_option( 'fusion_custom_templates' );
//if value exists and there are more than 1 number of templates
if ( $templates != false && count( $templates ) > 0 ) {
//generate column combinations
$combinations = Helper::generate_column_combinations( count( $templates ), $columns );
//add data in each column
for( $i = 0; $i < $columns; $i++) {
//if no data available for this column then break
if( $combinations[$i] == 0 ) { break; }
$counter = 0 ;
$content.= '
';
foreach( $templates as $key => $value ) {
$content.= '
';
$content.= '
';
$content.= '
'.$key.'';
$content.= '
';
//remove current element from array for next iteration
unset( $templates[$key] );
$counter++;
//if reached combination value then break loop
if ( $counter == $combinations[$i] ) { break; }
}
$content.= '
';
}
}
$content.= '
';
return $content;
}
/**
* Function to get get single template content
*
* @since 2.0.0
*
* @return Array Array having template data
*/
public function get_single_template () {
$custom_templates = get_option( 'fusion_custom_templates' );
//if value exists
if ( $custom_templates != false ) {
//print_r($custom_templates);
return $custom_templates[ stripslashes($_POST['name']) ];
} else {
return false;
}
}
/**
* Function to save single template data
*
* @since 2.0.0
*
* @return Boolean True for success and FALSE for failure
*/
public function save_single_template () {
$response = false;
$custom_templates = array();
//strip slashes and remove newline characters
$model = str_replace( "\n", "", stripslashes( $_POST['model'] ) );
$custom_templates = get_option( 'fusion_custom_templates' );
//if value exists
if ( $custom_templates === false ) {
$custom_templates = array();
$custom_templates[ stripslashes($_POST['name']) ] = $model;
$response = add_option( 'fusion_custom_templates', $custom_templates, '', 'no' );
} else {
$custom_templates[ stripslashes($_POST['name']) ] = $model;
$response = update_option( 'fusion_custom_templates', $custom_templates );
}
return $response;
}
public function delete_single_template () {
$response = false;
$custom_templates = array();
$custom_templates = get_option( 'fusion_custom_templates' );
//if templates exists
if ( $custom_templates != false ) {
//remove template
unset( $custom_templates[ stripslashes($_POST['name']) ] );
$response = update_option( 'fusion_custom_templates', $custom_templates );
}
return $response;
}
}
}