コード例 #1
0
/**
 * Create and write to the Dynamik Custom Template files.
 *
 * @since 1.2
 *
 */
function dynamik_write_custom_templates()
{
    dynamik_folders_open_permissions();
    $dynamik_templates = get_option('dynamik_gen_custom_templates');
    if (!empty($dynamik_templates)) {
        if (!is_dir(CHILD_DIR . '/my-templates')) {
            mkdir(CHILD_DIR . '/my-templates');
            @chmod(CHILD_DIR . '/my-templates', 0755);
        }
        foreach ($dynamik_templates as $dynamik_template => $template_bits) {
            if ($template_bits['template_type'] == 'page_template') {
                $dynamik_template_content = '<?php
/*
 * Template Name: ' . $template_bits['template_name'] . '
 */
?>

';
            } else {
                $dynamik_template_content = '<?php
/*
 * Custom WordPress Template: ' . $template_bits['template_name'] . '
 */
?>

';
            }
            $template_file_name = $template_bits['template_file_name'] == 'a404' ? '404' : $template_bits['template_file_name'];
            $dynamik_template_content .= $template_bits['template_textarea'];
            $handle = @fopen(dynamik_get_custom_template_paths($template_file_name, $template_bits['template_type']), 'w+');
            @fwrite($handle, htmlspecialchars_decode(stripslashes($dynamik_template_content)));
            @fclose($handle);
            $dynamik_template_content = '';
        }
    }
    dynamik_folders_close_permissions();
}
コード例 #2
0
ファイル: dynamik-templates.php プロジェクト: kabrewer07/mrw
/**
 * Delete Custom Template files when a Custom Options Reset occurs.
 *
 * @since 1.2
 */
function dynamik_reset_delete_template()
{
    $dynamik_templates = get_option('dynamik_gen_custom_templates');
    foreach ($dynamik_templates as $key => $value) {
        $template_file_name_value = $value['template_file_name'] == 'a404' ? '404' : $value['template_file_name'];
        unlink(dynamik_get_custom_template_paths($template_file_name_value, $value['template_type']));
    }
    return true;
}