protected function save_template($code, $path)
 {
     if (current_user_can('edit_themes') && !empty($code) && !empty($path)) {
         $saved = false;
         $file = get_stylesheet_directory() . '/' . learn_press_template_path() . '/' . $path;
         $code = stripslashes($code);
         if (is_writeable($file)) {
             $f = fopen($file, 'w+');
             if ($f !== false) {
                 fwrite($f, $code);
                 fclose($f);
                 $saved = true;
             }
         }
         if (!$saved) {
             $redirect = add_query_arg('learn_press_error', urlencode(__('Could not write to template file.', 'learn_press')));
             wp_redirect($redirect);
             exit;
         }
     }
 }
/**
 * Locate a template and return the path for inclusion.
 *
 * This is the load order:
 *
 *        yourtheme        /    $template_path    /    $template_name
 *        yourtheme        /    $template_name
 *        $default_path    /    $template_name
 *
 * @access public
 *
 * @param string $template_name
 * @param string $template_path (default: '')
 * @param string $default_path  (default: '')
 *
 * @return string
 */
function learn_press_locate_template($template_name, $template_path = '', $default_path = '')
{
    if (!$template_path) {
        $template_path = learn_press_template_path();
    }
    if (!$default_path) {
        $default_path = LPR_PLUGIN_PATH . '/templates/';
    }
    // Look within passed path within the theme - this is priority
    $template = locate_template(array(trailingslashit($template_path) . $template_name, $template_name));
    // Get default template
    if (!$template) {
        $template = $default_path . $template_name;
    }
    // Return what we found
    return apply_filters('learn_press_locate_template', $template, $template_name, $template_path);
}
Example #3
0
	</th>
	<td>
		<?php 
if (current_user_can('edit_themes') && (!empty($this->template_html) || !empty($this->template_plain))) {
    ?>
			<div id="templates">
				<?php 
    $templates = array('html' => __('HTML template', 'learn_press'), 'plain' => __('Plain text template', 'learn_press'));
    foreach ($templates as $template_type => $title) {
        $template = $this->get_template('template_' . $template_type);
        if (empty($template)) {
            continue;
        }
        $local_file = $this->get_theme_template_file($template);
        $template_file = $this->template_base . $template;
        $template_dir = learn_press_template_path();
        ?>
					<div class="template <?php 
        echo $template_type == 'html' ? $template_type . ' multipart' : 'plain_text';
        ?>
" style="display: none;">

						<?php 
        if (file_exists($local_file)) {
            ?>
							<?php 
            if ($template_type == 'plain') {
                ?>
								<div class="editor">
									<textarea name="<?php 
                echo $settings_class->get_field_name('emails_' . $this->id . '[email_content_plain]');