| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: Fresh Post |
|---|
| 4 | Plugin URI: http://freshoutcreative.com/goodies |
|---|
| 5 | Description: Create page templates with custom file uploads and integrated photo resizing. |
|---|
| 6 | Author: Freshout |
|---|
| 7 | Version: .11 |
|---|
| 8 | Author URI: http://freshoutcreative.com |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | if (is_admin()) |
|---|
| 12 | { |
|---|
| 13 | include_once('RCCWP_Constant.php'); |
|---|
| 14 | include_once('RCCWP_Application.php'); |
|---|
| 15 | |
|---|
| 16 | register_activation_hook(dirname(__FILE__) . '/Main.php', array('RCCWP_Application', 'Install')); |
|---|
| 17 | |
|---|
| 18 | if (get_option(RC_CWP_OPTION_KEY) !== false) |
|---|
| 19 | { |
|---|
| 20 | include_once('RCCWP_Menu.php'); |
|---|
| 21 | |
|---|
| 22 | //register_deactivation_hook(dirname(__FILE__) . '/Main.php', array('RCCWP_Application', 'Uninstall')); |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | add_action('admin_menu', array('RCCWP_Post', 'save_files') ); |
|---|
| 26 | |
|---|
| 27 | add_action('admin_menu', array('RCCWP_Menu', 'AttachCustomWritePanelMenuItems')); |
|---|
| 28 | add_action('admin_menu', array('RCCWP_Menu', 'DetachWpWritePanelMenuItems')); |
|---|
| 29 | |
|---|
| 30 | include_once('RCCWP_Processor.php'); |
|---|
| 31 | add_action('init', array('RCCWP_Processor', 'Main')); |
|---|
| 32 | add_action('admin_menu', array('RCCWP_Menu', 'AttachManagementMenuItem')); |
|---|
| 33 | add_action('admin_menu', array('RCCWP_Menu', 'AttachOptionsMenuItem')); |
|---|
| 34 | |
|---|
| 35 | include_once('RCCWP_Post.php'); |
|---|
| 36 | add_action('edit_post', array('RCCWP_Post', 'SetCustomWritePanel')); |
|---|
| 37 | add_action('save_post', array('RCCWP_Post', 'SetCustomWritePanel')); |
|---|
| 38 | add_action('publish_post', array('RCCWP_Post', 'SetCustomWritePanel')); |
|---|
| 39 | |
|---|
| 40 | add_action('edit_post', array('RCCWP_Post', 'SetMetaValue')); |
|---|
| 41 | add_action('save_post', array('RCCWP_Post', 'SetMetaValue')); |
|---|
| 42 | add_action('publish_post', array('RCCWP_Post', 'SetMetaValue')); |
|---|
| 43 | |
|---|
| 44 | add_filter('wp_redirect', array('RCCWP_Processor', 'Redirect')); |
|---|
| 45 | |
|---|
| 46 | add_action('shutdown', array('RCCWP_Processor', 'FlushAllOutputBuffer')); |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | require_once 'get-custom.php'; |
|---|
| 51 | |
|---|
| 52 | function cwp_add_type_identifier(){ |
|---|
| 53 | global $wpdb; |
|---|
| 54 | global $post; |
|---|
| 55 | |
|---|
| 56 | if( isset($_GET['custom-write-panel-id']) && !empty($_GET['custom-write-panel-id'])) |
|---|
| 57 | { |
|---|
| 58 | $getPostID = $wpdb->get_results("SELECT id, type FROM". RC_CWP_TABLE_WRITE_PANELS ." WHERE id='".$_GET['custom-write-panel-id']."'"); |
|---|
| 59 | echo "<input type=\"hidden\" id=\"post_type\" name=\"post_type\" value=\"". $getPostID[0]->type ."\" />"; |
|---|
| 60 | |
|---|
| 61 | } |
|---|
| 62 | else{ |
|---|
| 63 | if($post->post_type == 'page') { |
|---|
| 64 | echo "<input type=\"hidden\" id=\"post_type\" name=\"post_type\" value=\"page\" />"; |
|---|
| 65 | echo "<div id=\"message\" class=\"updated fade\"><p><strong>Page saved.</strong></p></div>"; |
|---|
| 66 | } else { |
|---|
| 67 | echo "<input type=\"hidden\" id=\"post_type\" name=\"post_type\" value=\"post\" />"; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | function cwp_add_pages_identifiers(){ |
|---|
| 74 | |
|---|
| 75 | $key = wp_create_nonce('rc-custom-write-panel'); |
|---|
| 76 | $id = $_GET['custom-write-panel-id']; |
|---|
| 77 | echo |
|---|
| 78 | <<<EOF |
|---|
| 79 | <input type="hidden" name="rc-custom-write-panel-verify-key" id="rc-custom-write-panel-verify-key" value="$key" /> |
|---|
| 80 | <input type="hidden" name="rc-cwp-custom-write-panel-id" value="$id" /> |
|---|
| 81 | EOF; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | add_action('edit_page_form','cwp_add_pages_identifiers'); |
|---|
| 85 | add_action('edit_form_advanced','cwp_add_type_identifier'); |
|---|
| 86 | ?> |
|---|