function mf_shortcodes($atts) { global $post, $FIELD_TYPES; extract(shortcode_atts(array('field' => 'no field defined or field name is wrong', 'eip' => FALSE, 'filtered' => FALSE, 'imgtag' => FALSE, 'label' => "", 'loop' => FALSE, 'loopseparator' => "|", 'checked' => "yes", 'groupindex' => 1, 'fieldindex' => 1), $atts)); if ($loop && RCCWP_CustomField::GetFieldDuplicates($post->ID, $field, $groupindex) > 1) { $fieldduplicatedata = get_field_duplicate($field); } else { $fielddata = RCCWP_CustomField::GetDataField($field, $groupindex, $fieldindex, $post->ID); } $fieldType = $fielddata['type']; $fieldID = $fielddata['id']; $fieldObject = $fielddata['properties']; $fieldValues = (array) $fielddata['meta_value']; $fieldMetaID = $fielddata['meta_id']; $fieldresults = GetProcessedFieldValue($fieldValues, $fieldType, $fieldObject); $shortcode_data = $fieldresults; if ($fielddata['type'] == $FIELD_TYPES['multiline_textbox'] && $filtered) { $shortcode_data = apply_filters('the_content', $fieldresults); } if ($fielddata['type'] == $FIELD_TYPES['image']) { $imgresults = split('&', $fieldresults); if ($imgtag) { $shortcode_data = "<img src=\"{$imgresults['0']}\"/>"; } else { $shortcode_data = $imgresults[0]; } } if ($fielddata['type'] == $FIELD_TYPES['listbox']) { $shortcode_data = implode(",", $fieldresults); } if ($fielddata['type'] == $FIELD_TYPES['checkbox_list']) { $shortcode_data = implode(",", $fieldresults); } if ($fielddata['type'] == $FIELD_TYPES['checkbox']) { if ($fieldresults) { $shortcode_data = $checked; } } if ($shortcode_data || $fieldduplicatedata) { if ($label) { $shortcode_data = $label . $shortcode_data; } else { $shortcode_data = get_label($field) . " : " . $shortcode_data; } ///// if ($field == "duplicate") { if ($loop) { return implode($loopseparator, $fieldduplicatedata); } else { return $shortcode_data; } } else { return $shortcode_data; } ///// } else { return "no data found, please check the field name"; } }
/** * Delete a group given id * * @param integer $customGroupId */ public static function Delete($customGroupId = null) { include_once 'RCCWP_CustomField.php'; if (isset($customGroupId)) { global $wpdb; $customFields = RCCWP_CustomGroup::GetCustomFields($customGroupId); foreach ($customFields as $field) { RCCWP_CustomField::Delete($field->id); } $wpdb->delete(MF_TABLE_PANEL_GROUPS, array('id' => $customGroupId), array('%d')); } }
/** * Delete a group given id * * @param integer $customGroupId */ function Delete($customGroupId = null) { include_once 'RCCWP_CustomField.php'; if (isset($customGroupId)) { global $wpdb; $customFields = RCCWP_CustomGroup::GetCustomFields($customGroupId); foreach ($customFields as $field) { RCCWP_CustomField::Delete($field->id); } $sql = sprintf("DELETE FROM " . RC_CWP_TABLE_PANEL_GROUPS . " WHERE id = %d", $customGroupId); $wpdb->query($sql); } }
function SetOptions() { global $mf_domain; $current_field = RCCWP_CustomField::GetCustomFieldTypes($_POST['custom-field-type']); $customGroupID = $_REQUEST['custom-group-id']; ?> <div class="wrap"> <h2><?php _e("Create Custom Field", $mf_domain); ?> </h2> <form action="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('finish-create-custom-field'); ?> " method="post" id="continue-create-new-field-form"> <input type="hidden" name="custom-group-id" value="<?php echo $_POST['custom-group-id']; ?> " /> <input type="hidden" name="custom-field-name" value="<?php echo htmlspecialchars($_POST['custom-field-name']); ?> " /> <input type="hidden" name="custom-field-description" value="<?php echo htmlspecialchars($_POST['custom-field-description']); ?> " /> <input type="hidden" name="custom-field-duplicate" value="<?php echo htmlspecialchars($_POST['custom-field-duplicate']); ?> " /> <input type="hidden" name="custom-field-order" value="<?php echo $_POST['custom-field-order']; ?> " /> <input type="hidden" name="custom-field-required" value="<?php echo $_POST['custom-field-required']; ?> " /> <input type="hidden" name="custom-field-type" value="<?php echo $_POST['custom-field-type']; ?> " /> <input type="hidden" name="custom-field-helptext" value="<?php echo $_POST['custom-field-helptext']; ?> " /> <!-- Hidden value for Image/Photo' Css Class--> <input type="hidden" name="custom-field-css" value="<?php echo $_POST['custom-field-css']; ?> " /> <h3><?php echo $current_field->name; ?> </h3> <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> <tbody> <?php if ($current_field->has_properties == "true") { ?> <?php if (in_array($current_field->name, array('Textbox', 'Listbox'))) { if ($current_field->name == 'Textbox') { $size = 25; } else { if ($current_field->name == 'Listbox') { $size = 3; } } ?> <tr valign="top"> <th scope="row"><?php _e('Size', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-size" id="custom-field-size" size="2" value="<?php echo $size; ?> " /></td> </tr> <?php } ?> <?php if (in_array($current_field->name, array('Multiline Textbox'))) { $height = 3; $width = 23; ?> <tr valign="top"> <th scope="row"><?php _e('Height', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-height" id="custom-field-height" size="2" value="<?php echo $height; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Width', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-width" id="custom-field-width" size="2" value="<?php echo $width; ?> " /></td> </tr> <?php } ?> <?php if (in_array($current_field->name, array('Slider'))) { $min_val = 0; $max_val = 10; $step = 1; ?> <tr valign="top"> <th scope="row"><?php _e('Value min', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-slider-min" id="custom-field-slider-min" size="2" value="<?php echo $min_val; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Value max', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-slider-max" id="custom-field-slider-max" size="2" value="<?php echo $max_val; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Stepping', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-slider-step" id="custom-field-slider-step" size="2" value="<?php echo $step; ?> " /></td> </tr> <?php } ?> <?php //eeble if (in_array($current_field->name, array('Related Type'))) { $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels(); ?> <tr valign="top"> <th scope="row"><?php _e('Related Type Panel', $mf_domain); ?> :</th> <td><select name="custom-field-related-type-panel-id" id="custom-field-related-type-panel-id"> <option value="-4">All Post</option> <option value="-3">All Page</option> <option value="-2">All Post with Write Panel</option> <option value="-1">All Page with Write Panel</option> <?php foreach ($customWritePanels as $panel) { ?> <option value="<?php echo $panel->id; ?> "><?php echo $panel->name; ?> </option> <?php } ?> </select></td> </tr> <?php } ?> <?php } // has_properties ?> <?php if ($current_field->has_options == "true") { ?> <tr valign="top"> <th scope="row"><?php _e('Options', $mf_domain); ?> :</th> <td> <textarea name="custom-field-options" id="custom-field-options" rows="2" cols="38"></textarea><br /> <em><?php _e('Separate each option with a newline.', $mf_domain); ?> </em> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Default Value', $mf_domain); ?> :</th> <td> <?php if ($current_field->allow_multiple_values == "true") { ?> <textarea name="custom-field-default-value" id="custom-field-default-value" rows="2" cols="38"></textarea><br /> <em><?php _e('Separate each value with a newline.', $mf_domain); ?> </em> <?php } else { ?> <input type="text" name="custom-field-default-value" id="custom-field-default-value" size="25" /> <?php } ?> </td> </tr> <?php } ?> <?php if ($current_field->has_properties && $current_field->name == 'Image') { ?> <tr valign="top"> <th scope="row"><?php _e('Options', $mf_domain); ?> :</th> <td> <?php _e('Max Height', $mf_domain); ?> : <input type="text" name="custom-field-photo-height" id="custom-field-photo-height"/> <?php _e('Max Width', $mf_domain); ?> : <input type="text" name="custom-field-photo-width" id="custom-field-photo-width" /> <?php _e('Custom', $mf_domain); ?> : <input type="text" name="custom-field-custom-params" id="custom-field-custom-params" /> <div style="color:blue;text-decoration:underline;" onclick="div=document.getElementById('params');div.style.display='';" > <?php _e('Custom Options List', $mf_domain); ?> </div> <div id="params" style="display:none;" onclick="this.style.display='none';"> <pre><?php echo param_list(); ?> </pre> </div> </td> </tr> <?php } ?> <!-- Date Custom Field --> <?php if ($current_field->has_properties && $current_field->name == 'Date') { ?> <tr valign="top"> <th scope="row"><?php _e('Options', $mf_domain); ?> :</th> <td> <?php _e('Format', $mf_domain); ?> : <select name="custom-field-date-format" id="custom-field-date-format"> <option value="m/d/Y">4/20/2008</option> <option value="l, F d, Y">Sunday, April 20, 2008</option> <option value="F d, Y">April 20, 2008</option> <option value="m/d/y">4/20/08</option> <option value="Y-m-d">2008-04-20</option> <option value="d-M-y">20-Apr-08</option> <option value="m.d.Y">4.20.2008</option> <option value="m.d.y">4.20.08</option> </select> </td> </tr> <?php } ?> <!-- Date Custom Field --> </tbody> </table> <p class="submit" > <a style="color:black" href="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field') . "&custom-group-id={$customGroupID}"; ?> " class="button"><?php _e('Cancel', $mf_domain); ?> </a> <input type="submit" id="finish-create-custom-field" value="<?php _e('Finish', $mf_domain); ?> " /> </p> </form> </div> <?php }
function get_audio($fieldName, $groupIndex = 1, $fieldIndex = 1) { require_once "RCCWP_CustomField.php"; global $wpdb, $post, $FIELD_TYPES; $fieldID = RCCWP_CustomField::GetIDByName($fieldName); $fieldObject = GetFieldInfo($fieldID); $fieldType = $wpdb->get_var("SELECT type FROM " . RC_CWP_TABLE_GROUP_FIELDS . " WHERE id='" . $fieldID . "'"); $single = true; switch ($fieldType) { case $FIELD_TYPES["checkbox_list"]: case $FIELD_TYPES["listbox"]: $single = false; break; } $fieldValues = (array) RCCWP_CustomField::GetCustomFieldValues($single, $post->ID, $fieldName, $groupIndex, $fieldIndex); if (!empty($fieldValues)) { $fieldValue = $fieldValues[0]; } else { return ""; } $path = FLUTTER_FILES_URI; $fieldValue = $path . $fieldValue; $finalString = stripslashes(trim("\\<div style=\\'padding-top:3px;\\'\\>\\<object classid=\\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\\' codebase='\\http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\\' width=\\'95%\\' height=\\'20\\' wmode=\\'transparent\\' \\>\\<param name=\\'movie\\' value=\\'" . FLUTTER_URI . "js/singlemp3player.swf?file=" . urlencode($fieldValue) . "\\' wmode=\\'transparent\\' /\\>\\<param name=\\'quality\\' value=\\'high\\' wmode=\\'transparent\\' /\\>\\<embed src=\\'" . FLUTTER_URI . "js/singlemp3player.swf?file=" . urlencode($fieldValue) . "' width=\\'50\\%\\' height=\\'20\\' quality=\\'high\\' pluginspage=\\'http://www.macromedia.com/go/getflashplayer\\' type=\\'application/x-shockwave-flash\\' wmode=\\'transparent\\' \\>\\</embed\\>\\</object\\>\\</div\\>")); return $finalString; }
<?php require dirname(__FILE__) . '/../../../wp-config.php'; if (!is_user_logged_in()) { die("Athentication failed!"); } if (isset($_GET['getFieldsByLetters']) && isset($_GET['letters'])) { $letters = $_GET['letters']; $letters = preg_replace("/[^a-z0-9 ]/si", "", $letters); // Search for similar fields global $wpdb; global $flutter_domain; require_once "RCCWP_CustomField.php"; $sql = "SELECT id, group_id FROM " . RC_CWP_TABLE_GROUP_FIELDS . " WHERE name like '%{$letters}%' "; $results = $wpdb->get_results($sql); foreach ($results as $result) { $fieldGroup = RCCWP_CustomGroup::Get($result->group_id); if ($_GET['panel_id'] != $fieldGroup->panel_id) { $currentField = RCCWP_CustomField::Get($result->id); $fieldDescription = "<b>{$currentField->description}</b> <br /> ("; $fieldDescription .= __("Type", $flutter_domain) . ":"; $fieldDescription .= " {$currentField->type}, "; $fieldDescription .= __("Name", $flutter_domain) . ":"; $fieldDescription .= " {$currentField->name})"; echo $result->id . "###" . $fieldDescription . "|"; } } }
/** * This function is executed every time to something related with the Magic Fields happen * this function update,delete,create a customfield,writepanel,group. */ function Main() { require_once 'RC_Format.php'; global $CUSTOM_WRITE_PANEL, $wp_version; if (isset($_POST['edit-with-no-custom-write-panel'])) { $type = RCCWP_Post::GetCustomWritePanel(); if (is_object($type)) { $ptype = $type->type; } else { $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post'; } wp_redirect($ptype . '.php?action=edit&post=' . $_POST['post-id'] . '&no-custom-write-panel'); } else { if (isset($_POST['edit-with-custom-write-panel']) && isset($_POST['custom-write-panel-id']) && (int) $_POST['custom-write-panel-id'] > 0) { if (substr($wp_version, 0, 3) >= 3.0) { $ptype = 'post'; } else { $type = RCCWP_Post::GetCustomWritePanel(); if (is_object($type)) { $ptype = $type->type; } else { $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post'; } } wp_redirect($ptype . '.php?action=edit&post=' . $_POST['post-id'] . '&custom-write-panel-id=' . $_POST['custom-write-panel-id']); } } if (empty($_REQUEST['mf_action'])) { $currentAction = ""; } else { $currentAction = $_REQUEST['mf_action']; } switch ($currentAction) { // ------------ Write Panels case 'finish-create-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; $default_theme_page = NULL; if ($_POST['radPostPage'] == 'page') { $default_theme_page = $_POST['page_template']; $default_parent_page = $_POST['parent_id']; } $customWritePanelId = RCCWP_CustomWritePanel::Create($_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page, $default_parent_page, $_POST['custom-write-panel-expanded']); wp_redirect(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $customWritePanelId)); break; case 'submit-edit-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; $default_theme_page = $default_parent_page = NULL; if ($_POST['radPostPage'] == 'page') { $default_theme_page = $_POST['page_template']; $default_parent_page = $_POST['parent_id']; } $default = array('custom-write-panel-id' => '', 'custom-write-panel-name' => '', 'custom-write-panel-standard-fields' => '', 'custom-write-panel-categories' => '', 'custom-write-panel-order' => '', 'single' => '', 'theme_page' => '', 'parent_page' => '', 'expanded' => ''); $_POST['theme_page'] = $default_theme_page; $_POST['parent_page'] = $default_parent_page; $save = array_merge($default, $_POST); RCCWP_CustomWritePanel::Update($save['custom-write-panel-id'], $save['custom-write-panel-name'], NULL, $save['custom-write-panel-standard-fields'], $save['custom-write-panel-categories'], $save['custom-write-panel-order'], FALSE, true, $save['single'], $save['theme_page'], $save['parent_page'], $save['custom-write-panel-expanded']); RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator'); break; case 'export-custom-write-panel': require_once 'RCCWP_CustomWritePanel.php'; $panelID = $_REQUEST['custom-write-panel-id']; $writePanel = RCCWP_CustomWritePanel::Get($panelID); // send file in header header('Content-type: binary'); header('Content-Disposition: attachment; filename="' . $writePanel->name . '.pnl"'); print RCCWP_CustomWritePanel::Export($panelID); exit; break; case 'delete-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; RCCWP_CustomWritePanel::Delete($_GET['custom-write-panel-id']); break; // ------------ Groups // ------------ Groups case 'finish-create-custom-group': include_once 'RCCWP_CustomGroup.php'; $default = array('custom-write-panel-id' => '', 'custom-group-name' => '', 'custom-group-duplicate' => '', 'custom-group-expanded' => ''); $values = array_merge($default, $_POST); $customGroupId = RCCWP_CustomGroup::Create($values['custom-write-panel-id'], $values['custom-group-name'], $values['custom-group-duplicate'], $values['custom-group-expanded'], NULL); break; case 'delete-custom-group': include_once 'RCCWP_CustomGroup.php'; $customGroup = RCCWP_CustomGroup::Get((int) $_REQUEST['custom-group-id']); RCCWP_CustomGroup::Delete($_GET['custom-group-id']); break; case 'unlink-write-panel': global $wpdb; $postId = (int) preg_replace('/post-/', '', $_REQUEST['post-id']); $dashboard = $_REQUEST['dashboard']; if ($postId) { //only delete images and postmeta fields with write panels if (count(get_post_meta($postId, RC_CWP_POST_WRITE_PANEL_ID_META_KEY))) { $query = sprintf('SELECT wp_pm.meta_value FROM %s mf_pm, %s mf_cf, %s wp_pm WHERE mf_pm.field_name = mf_cf.name AND mf_cf.type = 9 AND mf_pm.post_id = %d AND wp_pm.meta_id = mf_pm.id', MF_TABLE_POST_META, MF_TABLE_GROUP_FIELDS, $wpdb->postmeta, $postId); $images = $wpdb->get_results($query); foreach ($images as $image) { if ($image->meta_value != '') { $tmp = sprintf('%s%s', MF_FILES_PATH, $image->meta_value); @unlink($tmp); } } //delete all data of postmeta (WP and MF) $query = sprintf('DELETE a,b from %s a INNER JOIN %s b WHERE a.meta_id = b.id AND a.post_id = %d', $wpdb->postmeta, MF_TABLE_POST_META, $postId); $wpdb->query($query); } delete_post_meta($postId, RC_CWP_POST_WRITE_PANEL_ID_META_KEY); wp_redirect($dashboard); exit; } break; case 'submit-edit-custom-group': include_once 'RCCWP_CustomGroup.php'; $default = array('custom-write-panel-id' => '', 'custom-group-name' => '', 'custom-group-duplicate' => '', 'custom-group-expanded' => ''); $all = $_POST; $all['custom-group-id'] = $_REQUEST['custom-group-id']; $values = array_merge($default, $all); RCCWP_CustomGroup::Update($values['custom-group-id'], $values['custom-group-name'], $values['custom-group-duplicate'], $values['custom-group-expanded'], NULL); break; // ------------ Fields // ------------ Fields case 'copy-custom-field': include_once 'RCCWP_CustomField.php'; $fieldToCopy = RCCWP_CustomField::Get($_REQUEST['custom-field-id']); if (RCCWP_Processor::CheckFieldName($fieldToCopy->name, $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } RCCWP_CustomField::Create($_REQUEST['custom-group-id'], $fieldToCopy->name, $fieldToCopy->description, $fieldToCopy->display_order, $fieldToCopy->required_field, $fieldToCopy->type_id, $fieldToCopy->options, $fieldToCopy->default_value, $fieldToCopy->properties, $fieldToCopy->duplicate, $fieldToCopy->helptext); case 'continue-create-custom-field': if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } break; case 'finish-create-custom-field': include_once 'RCCWP_CustomField.php'; if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']); if ($current_field->has_properties) { $custom_field_properties = array(); if (in_array($current_field->name, array('Textbox', 'Listbox'))) { $custom_field_properties['size'] = $_POST['custom-field-size']; if (isset($_POST['strict-max-length'])) { $custom_field_properties['strict-max-length'] = $_POST['strict-max-length']; if (empty($custom_field_properties['size'])) { $custom_field_properties['size'] = 10; } } } else { if (in_array($current_field->name, array('Multiline Textbox'))) { $custom_field_properties['height'] = $_POST['custom-field-height']; $custom_field_properties['width'] = $_POST['custom-field-width']; if (isset($_POST['hide-visual-editor'])) { $custom_field_properties['hide-visual-editor'] = 1; } if (isset($_POST['strict-max-length'])) { $custom_field_properties['hide-visual-editor'] = 1; $custom_field_properties['strict-max-length'] = $_POST['strict-max-length']; if (empty($custom_field_properties['height'])) { $custom_field_properties['height'] = 4; } if (empty($custom_field_properties['width'])) { $custom_field_properties['width'] = 64; } } } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Image', 'Image (Upload Media)'))) { $params = ''; if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) { $params .= '&h=' . $_POST['custom-field-photo-height']; } if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) { $params .= '&w=' . $_POST['custom-field-photo-width']; } if ($_POST['custom-field-custom-params'] != '') { $params .= '&' . $_POST['custom-field-custom-params']; } if ($params) { $custom_field_properties['params'] = $params; } } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Slider'))) { $custom_field_properties['max'] = $_POST['custom-field-slider-max']; $custom_field_properties['min'] = $_POST['custom-field-slider-min']; $custom_field_properties['step'] = $_POST['custom-field-slider-step']; } else { if (in_array($current_field->name, array('Related Type'))) { $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id']; } } } } } } } } $default = array('custom-group-id' => '', 'custom-field-name' => '', 'custom-field-description' => '', 'custom-field-order' => '', 'custom-field-required' => '', 'custom-field-type' => '', 'custom-field-options' => '', 'custom-field-default-value' => '', 'prop' => '', 'custom-field-duplicate' => '', 'custom-field-helptext' => ''); $_POST['prop'] = $custom_field_properties; $save = array_merge($default, $_POST); RCCWP_CustomField::Create($save['custom-group-id'], $save['custom-field-name'], $save['custom-field-description'], $save['custom-field-order'], $save['custom-field-required'], $save['custom-field-type'], $save['custom-field-options'], $save['custom-field-default-value'], $save['prop'], $save['custom-field-duplicate'], $save['custom-field-helptext']); break; case 'submit-edit-custom-field': include_once 'RCCWP_CustomField.php'; $current_field_obj = RCCWP_CustomField::Get($_POST['custom-field-id']); if ($_POST['custom-field-name'] != $current_field_obj->name && RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-field') . '&custom-field-id=' . $_POST['custom-field-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_POST['custom-field-type']); if ($current_field->has_properties) { $custom_field_properties = array(); if (in_array($current_field->name, array('Textbox', 'Listbox'))) { $custom_field_properties['size'] = $_POST['custom-field-size']; if (isset($_POST['strict-max-length'])) { $custom_field_properties['strict-max-length'] = $_POST['strict-max-length']; if (empty($custom_field_properties['size'])) { $custom_field_properties['size'] = 10; } } } else { if (in_array($current_field->name, array('Multiline Textbox'))) { $custom_field_properties['height'] = $_POST['custom-field-height']; $custom_field_properties['width'] = $_POST['custom-field-width']; if (isset($_POST['hide-visual-editor'])) { $custom_field_properties['hide-visual-editor'] = 1; } if (isset($_POST['strict-max-length'])) { $custom_field_properties['hide-visual-editor'] = 1; $custom_field_properties['strict-max-length'] = $_POST['strict-max-length']; if (empty($custom_field_properties['height'])) { $custom_field_properties['height'] = 4; } if (empty($custom_field_properties['width'])) { $custom_field_properties['width'] = 64; } } } else { if (in_array($current_field->name, array('Image', 'Image (Upload Media)'))) { $params = ''; if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) { $params = '&h=' . $_POST['custom-field-photo-height']; } if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) { $params .= '&w=' . $_POST['custom-field-photo-width']; } if ($_POST['custom-field-custom-params'] != '') { $params .= '&' . $_POST['custom-field-custom-params']; } if ($params) { $custom_field_properties['params'] = $params; } } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Slider'))) { $custom_field_properties['max'] = $_POST['custom-field-slider-max']; $custom_field_properties['min'] = $_POST['custom-field-slider-min']; $custom_field_properties['step'] = $_POST['custom-field-slider-step']; } else { if (in_array($current_field->name, array('Related Type'))) { $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id']; } } } } } } } $default = array('custom-group-id' => '', 'custom-field-name' => '', 'custom-field-description' => '', 'custom-field-order' => '', 'custom-field-required' => '', 'custom-field-type' => '', 'custom-field-options' => '', 'custom-field-default-value' => '', 'prop' => '', 'custom-field-duplicate' => '', 'custom-field-helptext' => ''); $_POST['prop'] = $custom_field_properties; $save = array_merge($default, $_POST); RCCWP_CustomField::Update($save['custom-field-id'], $save['custom-field-name'], $save['custom-field-description'], $save['custom-field-order'], $save['custom-field-required'], $save['custom-field-type'], $save['custom-field-options'], $save['custom-field-default-value'], $save['prop'], $save['custom-field-duplicate'], $save['custom-field-helptext']); break; case 'delete-custom-field': include_once 'RCCWP_CustomField.php'; if (isset($_REQUEST['custom-field-id']) && !empty($_REQUEST['custom-field-id'])) { RCCWP_CustomField::Delete($_REQUEST['custom-field-id']); } break; case 'save-fields-order': RCCWP_CustomWritePanelPage::save_order_fields(); default: if (RCCWP_Application::InWritePostPanel()) { include_once 'RCCWP_Menu.php'; include_once 'RCCWP_WritePostPage.php'; $CUSTOM_WRITE_PANEL = RCCWP_Post::GetCustomWritePanel(); if (isset($CUSTOM_WRITE_PANEL) && !empty($CUSTOM_WRITE_PANEL)) { add_action('admin_head', array('RCCWP_WritePostPage', 'CustomFieldsCSS')); //adding javascripts files for the custom fields add_action('admin_print_scripts', array('RCCWP_WritePostPage', 'CustomFieldsJavascript')); add_action('admin_print_scripts', array('RCCWP_WritePostPage', 'ApplyWritePanelAssignedCategoriesOrTemplate')); add_action('admin_head', array('RCCWP_WritePostPage', 'ApplyCustomWritePanelHeader')); add_action('admin_menu', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface')); } else { if (!isset($_REQUEST['no-custom-write-panel']) && isset($_REQUEST['post'])) { include_once 'RCCWP_Options.php'; $promptEditingPost = RCCWP_Options::Get('prompt-editing-post'); if ($promptEditingPost == 1) { wp_redirect('?page=' . urlencode(MF_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&assign-custom-write-panel=' . (int) $_GET['post']); } } } } else { if (isset($_POST['update-custom-write-panel-options'])) { if ($_POST['uninstall-custom-write-panel'] == 'uninstall') { RCCWP_Application::Uninstall(); wp_redirect('options-general.php'); } else { if (isset($_POST['clear-cache-image-mf'])) { $dir = MF_CACHE_DIR; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (!is_dir($file)) { @unlink(MF_CACHE_DIR . $file); } } closedir($dh); } } } include_once 'RCCWP_Options.php'; $default = array('condense-menu' => 0, 'hide-non-standart-content' => 0, 'hide-write-post' => 0, 'hide-write-page' => 0, 'hide-visual-editor' => 0, 'dont-remove-tmce' => 0, 'prompt-editing-post' => 0, 'assign-to-role' => 0, 'default-custom-write-panel' => 0); $save_options = $_POST; unset($save_options['uninstall-custom-write-panel']); unset($save_options['update-custom-write-panel-options']); $save = array_merge($default, $save_options); RCCWP_Options::Update($save); } } } if (isset($_REQUEST['post'])) { // traversal addition to change write panel add_action('admin_menu', array('RCCWP_WritePostPage', 'CreateAttributesBox')); } } }
public static function PrepareModulesPanelsMenuItems() { $sub_menu_is_modules = false; if (empty($_REQUEST['mf_action'])) { $currentAction = ""; } else { $currentAction = $_REQUEST['mf_action']; } switch ($currentAction) { // ------------ Custom Fields case 'create-custom-field': $page_group = 'RCCWP_CreateCustomFieldPage'; $page_type = 'Main'; break; case 'continue-create-custom-field': if (isset($_REQUEST['custom-group-id']) && !empty($_REQUEST['custom-group-id'])) { $customGroupId = (int) $_REQUEST['custom-group-id']; } $customGroup = RCCWP_CustomGroup::Get($customGroupId); $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']); if ($current_field->has_options == "true" || $current_field->has_properties == "true") { $page_group = 'RCCWP_CreateCustomFieldPage'; $page_type = 'SetOptions'; } else { if ($current_field->has_options == "false") { $default = array('custom-group-id' => '', 'custom-field-name' => '', 'custom-field-description' => '', 'custom-field-order' => '', 'custom-field-required' => '', 'custom-field-type' => '', 'custom-field-options' => '', 'custom-field-duplicate' => '', 'custom-field-helptext' => ''); $save = array_merge($default, $_POST); RCCWP_CustomField::Create($save['custom-group-id'], $save['custom-field-name'], $save['custom-field-description'], $save['custom-field-order'], $save['custom-field-required'], $save['custom-field-type'], $save['custom-field-options'], null, null, $save['custom-field-duplicate'], $save['custom-field-helptext']); $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; } } break; case 'delete-custom-field': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'finish-create-custom-field': case 'cancel-edit-custom-field': case 'cancel-create-custom-field': case 'submit-edit-custom-field': case 'copy-custom-field': /* * Adding JS for sorting the order of the fields * using a drag and drop feature */ wp_enqueue_script('magic_set_categories', MF_URI . 'js/sorting_fields.js', array('jquery', 'jquery-ui-sortable')); $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'edit-custom-field': $page_group = 'RCCWP_CustomFieldPage'; $page_type = 'Edit'; break; // ------------ Groups // ------------ Groups case 'create-custom-group': $page_group = 'RCCWP_CreateCustomGroupPage'; $page_type = 'Main'; break; case 'view-custom-group': $page_group = 'RCCWP_CustomGroupPage'; $page_type = 'View'; break; case 'cancel-edit-custom-group': case 'cancel-create-custom-group': case 'delete-custom-group': case 'submit-edit-custom-group': case 'finish-create-custom-group': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'edit-custom-group': $page_group = 'RCCWP_CustomGroupPage'; $page_type = 'Edit'; break; // ------------ Custom Write Panels // ------------ Custom Write Panels case 'view-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; /* * Adding JS for sorting the order of the fields * using a drag and drop feature */ wp_enqueue_script('magic_set_categories', MF_URI . 'js/sorting_fields.js', array('jquery', 'jquery-ui-sortable')); break; case 'create-custom-write-panel': $page_group = 'RCCWP_CreateCustomWritePanelPage'; $page_type = 'Main'; break; case 'finish-create-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'edit-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'Edit'; break; case 'cancel-edit-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'submit-edit-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'import-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'Import'; break; default: if (isset($_REQUEST['assign-custom-write-panel'])) { $page_group = 'RCCWP_ManagementPage'; $page_type = 'AssignCustomWritePanel'; $sub_menu_is_modules = false; } else { if (isset($_REQUEST['cancel-edit-custom-group'])) { $page_group = 'RCCWP_CustomGroupPage'; $page_type = 'View'; } else { if (isset($_REQUEST['view-groups'])) { $page_group = 'RCCWP_ManagementPage'; $page_type = 'ViewGroups'; } else { $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'ViewWritePanels'; $sub_menu_is_modules = false; } } } } $result = null; if (!is_object($result)) { $result = new StdClass(); } if ($sub_menu_is_modules) { $result->panelsMenuFunction = array('RCCWP_CustomWritePanelPage', 'ViewWritePanels'); $result->modulesMenuFunction = array($page_group, $page_type); } else { $result->panelsMenuFunction = array($page_group, $page_type); $result->modulesMenuFunction = array('RCCWP_ManagementPage', 'ViewModules'); } return $result; }
/** * Updates the properties of a custom field. * * @param integer $customFieldId the id of the field to be updated * @param string $name the name of the field, the name is used to uniquely identify the field * when retrieving its value. * @param string $label the label of the field, the label is displayed beside the field * in Write tab. * @param integer $order the order of the field when it is displayed in * the Write tab. * @param integer $required_field whether this field is a required field. Required fields * doesn't allow users to save a post if they are null. * @param integer $type the type of the field. Use $FIELD_TYPES defined in MF_Constant.php * @param array $options array of strings that represent the list of the field if * its type is list. * @param array $default_value array of strings that represent default value(s) of * of the field if its type is list. * @param array $properties an array containing extra properties of the field. */ public static function Update($customFieldId, $name, $label, $order = 1, $required_field = 0, $type, $options = null, $default_value = null, $properties = null, $duplicate, $helptext = null) { global $wpdb; $oldCustomField = RCCWP_CustomField::Get($customFieldId); $name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); $name = str_replace(" ", "_", $name); $label = htmlspecialchars($label, ENT_QUOTES, 'UTF-8'); $helptext = htmlspecialchars($helptext, ENT_QUOTES, 'UTF-8'); if ($oldCustomField->name != $name) { $sql = $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_key = %s WHERE meta_key = %s", array($name, $oldCustomField->name)); $wpdb->query($sql); } $css = NULL; if (isset($_POST['custom-field-css'])) { $css = $_POST['custom-field-css']; } $sql = $wpdb->prepare("UPDATE " . MF_TABLE_GROUP_FIELDS . " SET name = %s" . " , description = %s" . " , display_order = %d" . " , required_field = %d" . " , type = %d" . " , CSS = '%s'" . " , duplicate = %d" . " , help_text = %s" . " WHERE id = %d", array(RC_Format::TextToSqlAlt($name), RC_Format::TextToSqlAlt($label), $order, $required_field, $type, $css, $duplicate, RC_Format::TextToSqlAlt($helptext), $customFieldId)); $wpdb->query($sql); $field_type = RCCWP_CustomField::GetCustomFieldTypes($type); if ($field_type->has_options == "true") { if (!is_array($options)) { $options = stripslashes($options); $options = explode("\n", $options); } array_walk($options, array("RC_Format", "TrimArrayValues")); $options = addslashes(serialize($options)); if (!is_array($default_value)) { $default_value = stripslashes($default_value); $default_value = explode("\n", $default_value); } array_walk($default_value, array("RC_Format", "TrimArrayValues")); $default_value = addslashes(serialize($default_value)); $sql = $wpdb->prepare("INSERT INTO " . MF_TABLE_CUSTOM_FIELD_OPTIONS . " (custom_field_id, options, default_option) values (%d, %s, %s)" . " ON DUPLICATE KEY UPDATE options = %s, default_option = %s", array($customFieldId, RC_Format::TextToSqlAlt($options), RC_Format::TextToSqlAlt($default_value), RC_Format::TextToSqlAlt($options), RC_Format::TextToSqlAlt($default_value))); $wpdb->query($sql); } else { $sql = $wpdb->prepare("DELETE FROM " . MF_TABLE_CUSTOM_FIELD_OPTIONS . " WHERE custom_field_id = %d", array($customFieldId)); $wpdb->query($sql); } if ($field_type->has_properties == "true") { $sql = $wpdb->prepare("INSERT INTO " . MF_TABLE_CUSTOM_FIELD_PROPERTIES . " (custom_field_id, properties) values (%d, %s)" . " ON DUPLICATE KEY UPDATE properties = %s", array($customFieldId, RC_Format::TextToSqlAlt(serialize($properties)), RC_Format::TextToSqlAlt(serialize($properties)))); $wpdb->query($sql); } else { $sql = $wpdb->prepare("DELETE FROM " . MF_TABLE_CUSTOM_FIELD_PROPERTIES . " WHERE custom_field_id = %d", array($customFieldId)); $wpdb->query($sql); } }
function mf_shortcodes($atts) { global $post, $FIELD_TYPES; extract(shortcode_atts(array('field' => 'no field defined or field name is wrong', 'eip' => FALSE, 'filtered' => FALSE, 'imgtag' => FALSE, 'label' => "", 'loop' => FALSE, 'loopseparator' => "|", 'checked' => "yes", 'groupindex' => 1, 'fieldindex' => 1), $atts)); if ($loop && RCCWP_CustomField::GetFieldDuplicates($post->ID, $field, $groupindex) > 1) { $fieldduplicatedata = get_field_duplicate($field); } else { $fielddata = RCCWP_CustomField::GetDataField($field, $groupindex, $fieldindex, $post->ID); } $fieldType = $fielddata['type']; $fieldID = $fielddata['id']; $fieldObject = $fielddata['properties']; $fieldValues = (array) $fielddata['meta_value']; $fieldMetaID = $fielddata['meta_id']; $fieldresults = GetProcessedFieldValue($fieldValues, $fieldType, $fieldObject); $shortcode_data = $fieldresults; if ($fielddata['type'] == $FIELD_TYPES['multiline_textbox'] && $filtered) { $shortcode_data = apply_filters('the_content', $fieldresults); } if ($fielddata['type'] == $FIELD_TYPES['image']) { $imgresults = split('&', $fieldresults); if ($imgtag) { $shortcode_data = "<img src=\"{$imgresults['0']}\"/>"; } else { $shortcode_data = $imgresults[0]; } } if ($fielddata['type'] == $FIELD_TYPES['listbox']) { $shortcode_data = implode(",", $fieldresults); } if ($fielddata['type'] == $FIELD_TYPES['checkbox_list']) { $shortcode_data = implode(",", $fieldresults); } if ($fielddata['type'] == $FIELD_TYPES['checkbox']) { if ($fieldresults) { $shortcode_data = $checked; } } // Prepare fields for EIP $enableEditnplace = RCCWP_Options::Get('enable-editnplace'); if ($eip && $enableEditnplace == 1 && current_user_can('edit_posts', $post->ID)) { switch ($fielddata['type']) { case $FIELD_TYPES["textbox"]: if (!$results) { $results = " "; } $shortcode_data = "<div class='" . EIP_textbox($fieldMetaID) . "' >" . $fieldresults . "</div>"; break; case $FIELD_TYPES["multiline_textbox"]: if (!$results) { $results = " "; } $shortcode_data = "<div class='" . EIP_mulittextbox($fieldMetaID) . "' >" . $shortcode_data . "</div>"; break; } } if ($shortcode_data || $fieldduplicatedata) { if ($label) { $shortcode_data = $label . $shortcode_data; } else { $shortcode_data = get_label($field) . " : " . $shortcode_data; } ///// if ($field == "duplicate") { if ($loop) { return implode($loopseparator, $fieldduplicatedata); } else { return $shortcode_data; } } else { return $shortcode_data; } ///// } else { return "no data found, please check the field name"; } }
function Main() { require_once 'RC_Format.php'; global $CUSTOM_WRITE_PANEL; wp_enqueue_script('jquery-ui-sortable'); if (isset($_POST['edit-with-no-custom-write-panel'])) { wp_redirect('post.php?action=edit&post=' . $_POST['post-id'] . '&no-custom-write-panel=' . $_POST['custom-write-panel-id']); } else { if (isset($_POST['edit-with-custom-write-panel'])) { wp_redirect('post.php?action=edit&post=' . $_POST['post-id'] . '&custom-write-panel-id=' . $_POST['custom-write-panel-id']); } } if (empty($_REQUEST['flutter_action'])) { $currentAction = ""; } else { $currentAction = $_REQUEST['flutter_action']; } switch ($currentAction) { // ------------ Write Panels case 'finish-create-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; $default_theme_page = NULL; if ($_POST['radPostPage'] == 'page') { $default_theme_page = $_POST['page_template']; } $customWritePanelId = RCCWP_CustomWritePanel::Create($_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page); wp_redirect(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $customWritePanelId)); break; case 'submit-edit-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; $default_theme_page = NULL; if ($_POST['radPostPage'] == 'page') { $default_theme_page = $_POST['page_template']; } RCCWP_CustomWritePanel::Update($_POST['custom-write-panel-id'], $_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page); RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator'); break; case 'export-custom-write-panel': require_once 'RCCWP_CustomWritePanel.php'; $panelID = $_REQUEST['custom-write-panel-id']; $writePanel = RCCWP_CustomWritePanel::Get($panelID); $exportedFilename = $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $writePanel->name . '.pnl'; RCCWP_CustomWritePanel::Export($panelID, $exportedFilename); // send file in header header('Content-type: binary'); header('Content-Disposition: attachment; filename="' . $writePanel->name . '.pnl"'); readfile($exportedFilename); unlink($exportedFilename); exit; break; case 'delete-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; RCCWP_CustomWritePanel::Delete($_GET['custom-write-panel-id']); //wp_redirect('?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php')); break; // ------------ Modules // ------------ Groups // ------------ Modules // ------------ Groups case 'finish-create-custom-group': include_once 'RCCWP_CustomGroup.php'; $customGroupId = RCCWP_CustomGroup::Create($_POST['custom-write-panel-id'], $_POST['custom-group-name'], $_POST['custom-group-duplicate'], $_POST['custom-group-at_right']); break; case 'delete-custom-group': include_once 'RCCWP_CustomGroup.php'; $customGroup = RCCWP_CustomGroup::Get((int) $_REQUEST['custom-group-id']); RCCWP_CustomGroup::Delete($_GET['custom-group-id']); break; case 'submit-edit-custom-group': include_once 'RCCWP_CustomGroup.php'; RCCWP_CustomGroup::Update($_REQUEST['custom-group-id'], $_POST['custom-group-name'], $_POST['custom-group-duplicate'], $_POST['custom-group-at_right']); break; // ------------ Fields // ------------ Fields case 'copy-custom-field': include_once 'RCCWP_CustomField.php'; $fieldToCopy = RCCWP_CustomField::Get($_REQUEST['custom-field-id']); if (RCCWP_Processor::CheckFieldName($fieldToCopy->name, $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } RCCWP_CustomField::Create($_REQUEST['custom-group-id'], $fieldToCopy->name, $fieldToCopy->description, $fieldToCopy->display_order, $fieldToCopy->required_field, $fieldToCopy->type_id, $fieldToCopy->options, $fieldToCopy->default_value, $fieldToCopy->properties, $fieldToCopy->duplicate); case 'continue-create-custom-field': if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } break; case 'finish-create-custom-field': include_once 'RCCWP_CustomField.php'; if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']); if ($current_field->has_properties) { $custom_field_properties = array(); if (in_array($current_field->name, array('Textbox', 'Listbox'))) { $custom_field_properties['size'] = $_POST['custom-field-size']; } else { if (in_array($current_field->name, array('Multiline Textbox'))) { $custom_field_properties['height'] = $_POST['custom-field-height']; $custom_field_properties['width'] = $_POST['custom-field-width']; } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Image'))) { $params = ''; if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) { $params .= '&h=' . $_POST['custom-field-photo-height']; } if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) { $params .= '&w=' . $_POST['custom-field-photo-width']; } if ($_POST['custom-field-custom-params'] != '') { $params .= '&' . $_POST['custom-field-custom-params']; } if ($params) { $custom_field_properties['params'] = $params; } } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Slider'))) { $custom_field_properties['max'] = $_POST['custom-field-slider-max']; $custom_field_properties['min'] = $_POST['custom-field-slider-min']; $custom_field_properties['step'] = $_POST['custom-field-slider-step']; } } } } } } } RCCWP_CustomField::Create($_POST['custom-group-id'], $_POST['custom-field-name'], $_POST['custom-field-description'], $_POST['custom-field-order'], $_POST['custom-field-required'], $_POST['custom-field-type'], $_POST['custom-field-options'], $_POST['custom-field-default-value'], $custom_field_properties, $_POST['custom-field-duplicate']); break; case 'submit-edit-custom-field': include_once 'RCCWP_CustomField.php'; $current_field_obj = RCCWP_CustomField::Get($_POST['custom-field-id']); if ($_POST['custom-field-name'] != $current_field_obj->name && RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-field') . '&custom-field-id=' . $_POST['custom-field-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_POST['custom-field-type']); if ($current_field->has_properties) { $custom_field_properties = array(); if (in_array($current_field->name, array('Textbox', 'Listbox'))) { $custom_field_properties['size'] = $_POST['custom-field-size']; } else { if (in_array($current_field->name, array('Multiline Textbox'))) { $custom_field_properties['height'] = $_POST['custom-field-height']; $custom_field_properties['width'] = $_POST['custom-field-width']; } else { if (in_array($current_field->name, array('Image'))) { $params = ''; if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) { $params = '&h=' . $_POST['custom-field-photo-height']; } if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) { $params .= '&w=' . $_POST['custom-field-photo-width']; } if ($_POST['custom-field-custom-params'] != '') { $params .= '&' . $_POST['custom-field-custom-params']; } if ($params) { $custom_field_properties['params'] = $params; } } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Slider'))) { $custom_field_properties['max'] = $_POST['custom-field-slider-max']; $custom_field_properties['min'] = $_POST['custom-field-slider-min']; $custom_field_properties['step'] = $_POST['custom-field-slider-step']; } } } } } } RCCWP_CustomField::Update($_POST['custom-field-id'], $_POST['custom-field-name'], $_POST['custom-field-description'], $_POST['custom-field-order'], $_POST['custom-field-required'], $_POST['custom-field-type'], $_POST['custom-field-options'], $_POST['custom-field-default-value'], $custom_field_properties, $_POST['custom-field-duplicate']); break; case 'delete-custom-field': include_once 'RCCWP_CustomField.php'; if (isset($_REQUEST['custom-group-id']) && !empty($_REQUEST['custom-group-id'])) { $customGroupId = (int) $_REQUEST['custom-group-id']; } $customGroup = RCCWP_CustomGroup::Get($customGroupId); RCCWP_CustomField::Delete($_REQUEST['custom-field-id']); break; case 'delete-theme-settings': include_once 'RCCWP_ThemeSettingsPage.php'; $settings = new RCCWP_ThemeSettingsPage(); $settings->remove_layout_setting(); break; case 'create-layout-setting': include_once 'RCCWP_ThemeSettingsPage.php'; if (!empty($_POST['variable_name'])) { RCCWP_ThemeSettingsPage::finish_create_layout_element(); break; } default: if (RCCWP_Application::InWritePostPanel()) { include_once 'RCCWP_Menu.php'; include_once 'RCCWP_WritePostPage.php'; $CUSTOM_WRITE_PANEL = RCCWP_Post::GetCustomWritePanel(); if (isset($CUSTOM_WRITE_PANEL) && $CUSTOM_WRITE_PANEL > 0) { ob_start(array('RCCWP_WritePostPage', 'ApplyCustomWritePanelAssignedCategories')); add_action('admin_head', array('RCCWP_WritePostPage', 'ApplyCustomWritePanelHeader')); // Allows fields to be added to right // commented to test add_action('submitpost_box', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterfaceRight'), 5); // add_action('submitpage_box', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterfaceRight'), 5); // commented to test add_action('add_meta_box', 'post', 'side', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterfaceRight')); // Allows fields to be added to the post edit body add_action('simple_edit_form', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'), 5); add_action('edit_form_advanced', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'), 5); add_action('edit_page_form', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface'), 5); } else { if (!isset($_REQUEST['no-custom-write-panel']) && isset($_REQUEST['post'])) { include_once 'RCCWP_Options.php'; $promptEditingPost = RCCWP_Options::Get('prompt-editing-post'); if ($promptEditingPost == 1) { wp_redirect('?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&assign-custom-write-panel=' . (int) $_GET['post']); } } } } else { if (isset($_POST['finish-create-custom-write-module'])) { include_once 'RCCWP_CustomWriteModule.php'; $customWriteModuleId = RCCWP_CustomWriteModule::Create($_POST['custom-write-module-name'], $_POST['custom-write-module-description']); //RCCWP_CustomWritePanel::AssignToRole($customWritePanelId, 'administrator'); if ($customWriteModuleId == -1) { //$_POST['create-custom-write-module'] = 1; $modulesURL = '?page=' . 'FlutterManageModules' . '&view-modules=1&create-custom-write-module=1&err_msg=-1'; wp_redirect($modulesURL); } else { wp_redirect(RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($customWriteModuleId)); } } else { if (isset($_POST['submit-edit-custom-write-module'])) { include_once 'RCCWP_CustomWriteModule.php'; $customWriteModuleId = RCCWP_CustomWriteModule::Update($_REQUEST['custom-write-module-id'], $_REQUEST['custom-write-module-name'], $_REQUEST['custom-write-module-description']); if ($customWriteModuleId == -1) { $customWriteModuleId = $_REQUEST['custom-write-module-id']; $modulesURL = '?page=' . 'FlutterManageModules' . "&edit-custom-write-module=1&view-custom-write-module={$customWriteModuleId}&custom-write-module-id={$customWriteModuleId}&err_msg=-1"; wp_redirect($modulesURL); } //RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator'); } else { if (isset($_POST['update-custom-write-panel-options'])) { if ($_POST['uninstall-custom-write-panel'] == 'uninstall') { RCCWP_Application::Uninstall(); wp_redirect('options-general.php'); } else { include_once 'RCCWP_Options.php'; $options['hide-write-post'] = $_POST['hide-write-post']; $options['hide-write-page'] = $_POST['hide-write-page']; $options['hide-visual-editor'] = $_POST['hide-visual-editor']; $options['prompt-editing-post'] = $_POST['prompt-editing-post']; $options['assign-to-role'] = $_POST['assign-to-role']; $options['use-snipshot'] = $_POST['use-snipshot']; $options['enable-editnplace'] = $_POST['enable-editnplace']; $options['eip-highlight-color'] = $_POST['eip-highlight-color']; $options['enable-swfupload'] = $_POST['enable-swfupload']; $options['enable-browserupload'] = $_POST['enable-browserupload']; $options['default-custom-write-panel'] = $_POST['default-custom-write-panel']; $options['enable-HTMLPurifier'] = $_POST['enable-HTMLPurifier']; $options['tidy-level'] = $_POST['tidy-level']; $options['canvas_show_instructions'] = $_POST['canvas_show_instructions']; $options['canvas_show_zone_name'] = $_POST['canvas_show_zone_name']; $options['canvas_show'] = $_POST['canvas_show']; $options['ink_show'] = $_POST['ink_show']; RCCWP_Options::Update($options); } } else { if (isset($_REQUEST['create-module-duplicate'])) { include_once 'RCCWP_ModuleDuplicate.php'; $moduleID = $_REQUEST['custom-write-module-id']; RCCWP_ModuleDuplicate::Create($moduleID); wp_redirect(RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($moduleID)); } else { if (isset($_POST['submit-edit-module-duplicate'])) { include_once 'RCCWP_ModuleDuplicate.php'; $moduleID = $_REQUEST['custom-write-module-id']; RCCWP_ModuleDuplicate::Update($_REQUEST['module-duplicate-id'], $_REQUEST['module-duplicate-name']); wp_redirect('?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&view-custom-write-module=' . $moduleID . '&custom-write-module-id=' . $moduleID); } else { if (isset($_REQUEST['delete-module-duplicate'])) { include_once 'RCCWP_ModuleDuplicate.php'; $moduleID = $_REQUEST['custom-write-module-id']; RCCWP_ModuleDuplicate::Delete($_REQUEST['module-duplicate-id']); wp_redirect(RCCWP_ManagementPage::GetCustomWriteModuleEditUrl($moduleID)); } else { if (isset($_POST['delete-custom-write-module'])) { include_once 'RCCWP_CustomWriteModule.php'; $moduleID = $_REQUEST['custom-write-module-id']; RCCWP_CustomWriteModule::Delete($moduleID); wp_redirect('?page=' . urlencode(FLUTTER_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&view-modules=1'); } } } } } } } } } }
/** * Updates the properties of a custom field. * * @param integer $customFieldId the id of the field to be updated * @param string $name the name of the field, the name is used to uniquely identify the field * when retrieving its value. * @param string $label the label of the field, the label is displayed beside the field * in Write tab. * @param integer $order the order of the field when it is displayed in * the Write tab. * @param integer $required_field whether this field is a required field. Required fields * doesn't allow users to save a post if they are null. * @param integer $type the type of the field. Use $FIELD_TYPES defined in RCCWP_Constant.php * @param array $options array of strings that represent the list of the field if * its type is list. * @param array $default_value array of strings that represent default value(s) of * of the field if its type is list. * @param array $properties an array containing extra properties of the field. */ function Update($customFieldId, $name, $label, $order = 1, $required_field = 0, $type, $options = null, $default_value = null, $properties = null, $duplicate) { global $wpdb; $oldCustomField = RCCWP_CustomField::Get($customFieldId); if ($oldCustomField->name != $name) { $sql = sprintf("UPDATE {$wpdb->postmeta}" . " SET meta_key = %s" . " WHERE meta_key = %s", RC_Format::TextToSql($name), RC_Format::TextToSql($oldCustomField->name)); $wpdb->query($sql); } $sql = sprintf("UPDATE " . RC_CWP_TABLE_GROUP_FIELDS . " SET name = %s" . " , description = %s" . " , display_order = %d" . " , required_field = %d" . " , type = %d" . " , CSS = '%s'" . " , duplicate = %d" . " WHERE id = %d", RC_Format::TextToSql($name), RC_Format::TextToSql($label), $order, $required_field, $type, $_POST['custom-field-css'], $duplicate, $customFieldId); $wpdb->query($sql); $field_type = RCCWP_CustomField::GetCustomFieldTypes($type); if ($field_type->has_options == "true") { if (!is_array($options)) { $options = stripslashes($options); $options = explode("\n", $options); } array_walk($options, array(RC_Format, TrimArrayValues)); $options = addslashes(serialize($options)); if (!is_array($default_value)) { $default_value = stripslashes($default_value); $default_value = explode("\n", $default_value); } array_walk($default_value, array(RC_Format, TrimArrayValues)); $default_value = addslashes(serialize($default_value)); $sql = sprintf("INSERT INTO " . RC_CWP_TABLE_CUSTOM_FIELD_OPTIONS . " (custom_field_id, options, default_option) values (%d, %s, %s)" . " ON DUPLICATE KEY UPDATE options = %s, default_option = %s", $customFieldId, RC_Format::TextToSql($options), RC_Format::TextToSql($default_value), RC_Format::TextToSql($options), RC_Format::TextToSql($default_value)); $wpdb->query($sql); } else { $sql = sprintf("DELETE FROM " . RC_CWP_TABLE_CUSTOM_FIELD_OPTIONS . " WHERE custom_field_id = %d", $customFieldId); $wpdb->query($sql); } if ($field_type->has_properties == "true") { $sql = sprintf("INSERT INTO " . RC_CWP_TABLE_CUSTOM_FIELD_PROPERTIES . " (custom_field_id, properties) values (%d, %s)" . " ON DUPLICATE KEY UPDATE properties = %s", $customFieldId, RC_Format::TextToSql(serialize($properties)), RC_Format::TextToSql(serialize($properties))); $wpdb->query($sql); } else { $sql = sprintf("DELETE FROM " . RC_CWP_TABLE_CUSTOM_FIELD_PROPERTIES . " WHERE custom_field_id = %d", $customFieldId); $wpdb->query($sql); } }
function SliderInterface($customField, $inputName, $groupCounter, $fieldCounter, $fieldValue = NULL) { $customFieldId = $customField->id; if (!empty($_REQUEST['post'])) { $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); } else { $value = 0; } if ($fieldValue) { $value = $fieldValue; } else { if (!empty($_REQUEST['post'])) { $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); } else { $value = 0; } } if (!$customField->properties['min']) { $customField->properties['min'] = 0; } if (!$value) { $value = $customField->properties['min']; } if (!$customField->properties['max']) { $customField->properties['max'] = 100; } if (!$customField->properties['step']) { $customField->properties['step'] = 1; } ?> <script> jQuery('document').ready(function(){ jQuery('#slider_<?php echo $inputName; ?> ').slider({ range: false, value: <?php echo $value; ?> , min: <?php echo $customField->properties['min']; ?> , max: <?php echo $customField->properties['max']; ?> , step: <?php echo $customField->properties['step']; ?> , handles: [{ start: <?php echo $value; ?> , step: <?php echo $customField->properties['step']; ?> , min: <?php echo $customField->properties['min']; ?> , max: <?php echo $customField->properties['max']; ?> , id: 'slider_<?php echo $inputName; ?> ' }], 'slide': function(e, ui) { jQuery('#slide_value_<?php echo $inputName; ?> ').empty(); jQuery('#slide_value_<?php echo $inputName; ?> ').append(ui.value); jQuery('#<?php echo $inputName; ?> ').val(ui.value); } }); }); </script> <div id='slider_<?php echo $inputName; ?> ' class='ui-slider-2' style="margin:40px;"> <div class='ui-slider-handle'> <div class="slider_numeber_show" id="slide_value_<?php echo $inputName; ?> "> <?php echo $value; ?> </div> </div> </div> <input type="hidden" id="<?php echo $inputName; ?> " name="<?php echo $inputName; ?> " value="<?php echo $value; ?> " /> <?php }
/** * Import a write panel given the file path. * @param string $panelFilePath the full path of the panel file * @param string $writePanelName the write panel name, if this value if false, the function will * use the pnl filename as the write panel name. The default value is false * @return the panel id, or false in case of error. */ function Import($panelFilePath, $writePanelName = false) { include_once 'RCCWP_CustomGroup.php'; include_once 'RCCWP_CustomField.php'; include_once 'RCCWP_Application.php'; if (!$writePanelName) { //use filename $writePanelName = basename($panelFilePath, ".pnl"); } if ($writePanelName == '') { return false; } // Append a number if the panel already exists, $i = 1; $newWritePanelName = $writePanelName; //while (file_exists(FLUTTER_MODULES_DIR.$newModuleName)){ // $newModuleName = $moduleName. "_" . $i++; //} //$moduleName = $newModuleName; // Unserialize file $imported_data = unserialize(file_get_contents($panelFilePath)); $types_results = RCCWP_CustomField::GetCustomFieldTypes(); $types = array(); foreach ($types_results as $types_result) { $types[$types_result->name] = $types_result->id; } // Prepare categories list $assignedCategories = array(); foreach ($imported_data['panel']->assignedCategories as $cat_name) { $assignedCategories[] = wp_create_category($cat_name); } //Create write panel $writePanelID = RCCWP_CustomWritePanel::Create($writePanelName, $imported_data['panel']->description, $imported_data['panel']->standardFieldsIDs, $assignedCategories, $imported_data['panel']->display_order, $imported_data['panel']->type, false, $imported_data['panel']->single, $imported_data['panel']->theme); foreach ($imported_data['fields'] as $groupName => $group) { // For backward compatability if (!isset($group->fields)) { $newGroup->fields = $group; $group = $newGroup; } // Import group $groupID = RCCWP_CustomGroup::Create($writePanelID, $groupName, $group->duplicate, $group->at_right); // Import group fields foreach ($group->fields as $field) { $fieldOptions = @implode("\n", $field->options); $fieldDefault = @implode("\n", $field->default_value); RCCWP_CustomField::Create($groupID, $field->name, $field->description, $field->display_order, $field->required_field, $types[$field->type], $fieldOptions, $fieldDefault, $field->properties, $field->duplicate); } } return $writePanelID; }
function create_layout_element() { global $flutter_domain; ?> <div class="wrap"> <h2><?php _e('Create a new layout Setting', $flutter_domain); ?> </h2> <br/> <form method="post" action="?page=RCCWP_ThemeSettingsPage&flutter_action=create-layout-setting&save=true"> <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> <tbody> <tr valing="top"> <th><?php _e('Name', $flutter_domain); ?> </th> <td> <input type="text" name="variable_name"/> </td> </tr> <tr valing="top"> <th><?php _e('Description', $flutter_domain); ?> </th> <td> <textarea name="description"></textarea> </td> </tr> <tr valing="top"> <th><?php _e('Type', $flutter_domain); ?> </th> <td> <?php $field_types = RCCWP_CustomField::GetCustomFieldTypes(); foreach ($field_types as $field) { $checked = $field->name == RCCWP_CustomField::GetDefaultCustomFieldType() ? 'checked="checked"' : ''; ?> <label><input name="custom-field-type" value="<?php echo $field->id; ?> " type="radio" <?php echo $checked; ?> > <?php echo $field->name; ?> </label><br /> <?php } ?> </td> </tr> <tr> <th></th> <td> <input type="submit" id="continue-create-custom-field" value="<?php _e('Create', $flutter_domain); ?> " onclick="submitForm=true;"/> </td> </tr> </tbody> </form> <p class="submit" > </p> </div> <?php }
public static function MediaPhotoInterface($customField, $inputName, $groupCounter, $fieldCounter) { global $mf_domain, $post; $idField = RCCWP_WritePostPage::changeNameInput($inputName); if (!empty($_GET['post'])) { $hidValue = RCCWP_CustomField::GetCustomFieldValues(true, $_GET['post'], $customField->name, $groupCounter, $fieldCounter); } else { $hidValue = ''; } $filepath = $inputName . '_filepath'; //The Image is required? $requiredClass = ""; if ($customField->required_field) { $requiredClass = "field_required"; } $imageThumbID = "img_thumb_" . $idField; $value = "<img src='" . MF_URI . "images/noimage.jpg' id='{$imageThumbID}'/>"; if (!empty($hidValue)) { $path = PHPTHUMB . "?src="; $info = wp_get_attachment_image_src($hidValue, 'original'); $path_image_media = $info[0]; $value = $path . $path_image_media . "&w=150&h=120&zc=1"; $value = "<img src='{$value}' id='{$imageThumbID}'/>"; } ?> <p class="error_msg_txt" id="upload_progress_<?php echo $idField; ?> " style="visibility:hidden;height:0px"> </p> <div id="image_photo" style="width:150px; float: left"> <?php echo $value; ?> <div id="photo_edit_link_<?php echo $idField; ?> " class="photo_edit_link"> <?php if ($hidValue) { echo " <strong><a href='#remove' class='remove_media' id='remove-{$idField}'>" . __("Remove Image", $mf_domain) . "</a></strong>"; } ?> </div> </div> <div id="image_input" style="padding-left: 170px;"> <?php if (empty($requiredClass)) { $requiredClass = ''; } ?> <div class="mf_custom_field"> <input tabindex="3" id="<?php echo $idField; ?> " name="<?php echo $inputName; ?> " type="hidden" class="<?php echo $requiredClass; ?> " size="46" value="<?php echo $hidValue; ?> " <?php if ($customField->required_field) { echo 'validate="required:true"'; } ?> /> <?php $thumb_class = 'thickbox1'; if (is_wp30()) { $thumb_class = 'thickbox'; } ?> <a class="<?php echo $thumb_class; ?> update_field_media_upload" id="thumb_<?php echo $idField; ?> " href="media-upload.php?post_id=<?php echo $post->ID; ?> &type=image&TB_iframe=1" ><?php _e('Set Image', $mf_domain); ?> </a> </div> <?php if (!is_wp30()) { ?> <script> jQuery(document).ready(function(){ tb_init('a#thumb_<?php echo $idField; ?> '); jQuery('a#thumb_<?php echo $idField; ?> ').click( function(){ window.mf_field_id = jQuery(this).attr('id'); }); }); </script> <?php } ?> </div> <div style="clear: both; height: 1px;"> </div> <?php if ($customField->required_field) { ?> <div class="mf_message_error"><label for="<?php echo $inputName; ?> " class="error_magicfields error"><?php _e("This field is required", $mf_domain); ?> </label></div> <?php } ?> <?php }
function SliderInterface($customField, $inputName, $groupCounter, $fieldCounter, $fieldValue = NULL) { $customFieldId = $customField->id; $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); if ($fieldValue) { $value = $fieldValue; } else { $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); } if (!$customField->properties['min']) { $customField->properties['min'] = 0; } if (!$value) { $value = $customField->properties['min']; } if (!$customField->properties['max']) { $customField->properties['max'] = 100; } if (!$customField->properties['step']) { $customField->properties['step'] = 0; } ?> <link rel="stylesheet" href="<?php echo FLUTTER_URI; ?> css/flora.slider.css" type="text/css" media="screen" title="Flora (Default)"> <script type="text/javascript" src="<?php echo FLUTTER_URI; ?> js/ui.slider.js"></script> <script type="text/javascript"> jQuery('document').ready(function(){ jQuery('#slider_<?php echo $inputName; ?> ').slider({range: true, start: <?php echo $value; ?> , min: <?php echo $customField->properties['min']; ?> , max: <?php echo $customField->properties['max']; ?> , stepping: <?php echo $customField->properties['step']; ?> , handles: [ {start: <?php echo $value; ?> , stepping: <?php echo $customField->properties['step']; ?> ,min: <?php echo $customField->properties['min']; ?> , max: <?php echo $customField->properties['max']; ?> , id: 'slider_<?php echo $inputName; ?> '} ] //,change: function(e,ui) { // jQuery('#slide_value_<?php echo $inputName; ?> ').empty(); // jQuery('#slide_value_<?php echo $inputName; ?> ').append(ui.value); // jQuery('#<?php echo $inputName; ?> ').val(ui.value); // } ,'slide': function(e, ui){ jQuery('#slide_value_<?php echo $inputName; ?> ').empty(); jQuery('#slide_value_<?php echo $inputName; ?> ').append(ui.value); jQuery('#<?php echo $inputName; ?> ').val(ui.value); } }); //jQuery('#slider_<?php echo $inputName; ?> ').slider("moveTo", "+=6") //jQuery('#slider_<?php echo $inputName; ?> ').slider("value", "9") }); </script> <style> .slider_numeber_show{ margin-top: -16px; padding-left: 3px; } </style> <div id='slider_<?php echo $inputName; ?> ' class='ui-slider-2' style="margin:40px;"> <div class='ui-slider-handle'><div class="slider_numeber_show" id="slide_value_<?php echo $inputName; ?> "> <?php echo $value; ?> </div></div> </div> <input type="hidden" id="<?php echo $inputName; ?> " name="<?php echo $inputName; ?> " value="<?php echo $value; ?> " /> <?php }
function get_label($fieldName, $post_id = NULL) { require_once "RCCWP_CustomField.php"; global $post; if (!$post_id) { $post_id = $post->ID; } $field = RCCWP_CustomField::GetInfoByName($fieldName, $post_id); if (!$field) { return FALSE; } return $field['description']; }
/** * Import a write panel given the file path. * @param string $panelFilePath the full path of the panel file * @param string $writePanelName the write panel name, if this value if false, the function will * use the pnl filename as the write panel name. The default value is false * @param boolean $overwrite whether to overwrite existing panels with the same name * @return the panel id, or false in case of error. */ function Import($panelFilePath, $writePanelName = false, $overwrite = false) { global $wpdb; include_once 'RCCWP_CustomGroup.php'; include_once 'RCCWP_CustomField.php'; include_once 'RCCWP_Application.php'; if (!$writePanelName) { //use filename $writePanelName = basename($panelFilePath, ".pnl"); } if ($writePanelName == '') { return false; } $writePanelID = RCCWP_CustomWritePanel::GetIdByName($writePanelName); if ($writePanelID && !$overwrite) { // Append a number if the panel already exists, $i = 2; $temp_name = $writePanelName . "_1"; while (RCCWP_CustomWritePanel::GetIdByName($temp_name)) { $temp_name = $writePanelName . "_" . $i++; } $writePanelName = $temp_name; } // Unserialize file $imported_data = unserialize(file_get_contents($panelFilePath)); $types_results = RCCWP_CustomField::GetCustomFieldTypes(); $types = array(); foreach ($types_results as $types_result) { $types[$types_result->name] = $types_result->id; } // Prepare categories list $assignedCategories = array(); if (is_array($imported_data['panel']->assignedCategories)) { foreach ($imported_data['panel']->assignedCategories as $cat_name) { wp_create_category($cat_name); $assignedCategories[] = $cat_name; } } //Create write panel if ($writePanelID && $overwrite) { RCCWP_CustomWritePanel::Update($existingPanelId, $writePanelName, $imported_data['panel']->description, $imported_data['panel']->standardFieldsIDs, $assignedCategories, $imported_data['panel']->display_order, $imported_data['panel']->type, false, $imported_data['panel']->single, $imported_data['panel']->theme, $imported_data['panel']->parent_page); foreach (RCCWP_CustomWritePanel::GetCustomGroups($writePanelID) as $group) { RCCWP_CustomGroup::Delete($group->id); } } else { $writePanelID = RCCWP_CustomWritePanel::Create($writePanelName, $imported_data['panel']->description, $imported_data['panel']->standardFieldsIDs, $assignedCategories, $imported_data['panel']->display_order, $imported_data['panel']->type, false, $imported_data['panel']->single, $imported_data['panel']->theme, $imported_data['panel']->parent_page); } if (is_array($imported_data['fields'])) { foreach ($imported_data['fields'] as $groupName => $group) { // For backward compatability if (!isset($group->fields)) { $newGroup->fields = $group; $group = $newGroup; } // Import group $groupID = RCCWP_CustomGroup::Create($writePanelID, $groupName, $group->duplicate, $group->at_right); // Import group fields foreach ($group->fields as $field) { $fieldOptions = @implode("\n", $field->options); $fieldDefault = @implode("\n", $field->default_value); if ($field->type == "Related Type") { $field->properties["panel_id"] = RCCWP_CustomWritePanel::GetIdByName($field->properties["panel_name"]); unset($field->properties["panel_name"]); } RCCWP_CustomField::Create($groupID, $field->name, $field->description, $field->display_order, $field->required_field, $types[$field->type], $fieldOptions, $fieldDefault, $field->properties, $field->duplicate, $field->help_text); } } } return $writePanelID; }
function PrepareModulesPanelsMenuItems() { $sub_menu_is_modules = false; if (empty($_REQUEST['mf_action'])) { $currentAction = ""; } else { $currentAction = $_REQUEST['mf_action']; } switch ($currentAction) { // ------------ Custom Fields case 'create-custom-field': $page_group = 'RCCWP_CreateCustomFieldPage'; $page_type = 'Main'; break; case 'continue-create-custom-field': if (isset($_REQUEST['custom-group-id']) && !empty($_REQUEST['custom-group-id'])) { $customGroupId = (int) $_REQUEST['custom-group-id']; } $customGroup = RCCWP_CustomGroup::Get($customGroupId); $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']); if ($current_field->has_options == "true" || $current_field->has_properties == "true") { $page_group = 'RCCWP_CreateCustomFieldPage'; $page_type = 'SetOptions'; } else { if ($current_field->has_options == "false") { $default = array('custom-group-id' => '', 'custom-field-name' => '', 'custom-field-description' => '', 'custom-field-order' => '', 'custom-field-required' => '', 'custom-field-type' => '', 'custom-field-options' => '', 'custom-field-duplicate' => '', 'custom-field-helptext' => ''); $save = array_merge($default, $_POST); RCCWP_CustomField::Create($save['custom-group-id'], $save['custom-field-name'], $save['custom-field-description'], $save['custom-field-order'], $save['custom-field-required'], $save['custom-field-type'], $save['custom-field-options'], null, null, $save['custom-field-duplicate'], $save['custom-field-helptext']); $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; } } break; case 'delete-custom-field': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'finish-create-custom-field': case 'cancel-edit-custom-field': case 'cancel-create-custom-field': case 'submit-edit-custom-field': case 'copy-custom-field': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'edit-custom-field': $page_group = 'RCCWP_CustomFieldPage'; $page_type = 'Edit'; break; // ------------ Groups // ------------ Groups case 'create-custom-group': $page_group = 'RCCWP_CreateCustomGroupPage'; $page_type = 'Main'; break; case 'view-custom-group': $page_group = 'RCCWP_CustomGroupPage'; $page_type = 'View'; break; case 'cancel-edit-custom-group': case 'cancel-create-custom-group': case 'delete-custom-group': case 'submit-edit-custom-group': case 'finish-create-custom-group': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'edit-custom-group': $page_group = 'RCCWP_CustomGroupPage'; $page_type = 'Edit'; break; // ------------ Custom Write Panels // ------------ Custom Write Panels case 'view-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'create-custom-write-panel': $page_group = 'RCCWP_CreateCustomWritePanelPage'; $page_type = 'Main'; break; case 'finish-create-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'edit-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'Edit'; break; case 'cancel-edit-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'submit-edit-custom-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'View'; break; case 'import-write-panel': $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'Import'; break; default: if (isset($_REQUEST['assign-custom-write-panel'])) { $page_group = 'RCCWP_ManagementPage'; $page_type = 'AssignCustomWritePanel'; $sub_menu_is_modules = false; } else { if (isset($_REQUEST['cancel-edit-custom-group'])) { $page_group = 'RCCWP_CustomGroupPage'; $page_type = 'View'; } else { if (isset($_REQUEST['view-groups'])) { $page_group = 'RCCWP_ManagementPage'; $page_type = 'ViewGroups'; } else { $page_group = 'RCCWP_CustomWritePanelPage'; $page_type = 'ViewWritePanels'; $sub_menu_is_modules = false; } } } } if ($sub_menu_is_modules) { $result->panelsMenuFunction = array('RCCWP_CustomWritePanelPage', 'ViewWritePanels'); $result->modulesMenuFunction = array($page_group, $page_type); } else { $result->panelsMenuFunction = array($page_group, $page_type); $result->modulesMenuFunction = array('RCCWP_ManagementPage', 'ViewModules'); } return $result; }
function Edit() { global $FIELD_TYPES; global $flutter_domain; $custom_field = RCCWP_CustomField::Get((int) $_GET['custom-field-id']); $customGroupID = $custom_field->group_id; if (in_array($custom_field->type, array('Image'))) { $cssVlaue = $custom_field->CSS; } ?> <div class="wrap"> <h2><?php _e('Edit Custom Field', $flutter_domain); ?> - <?php echo $custom_field->description; ?> </h2> <br class="clear" /> <?php if (isset($_GET['err_msg'])) { switch ($_GET['err_msg']) { case -1: ?> <div class="error"><p> <?php _e('A field with the same name already exists in this write panel. Please choose a different name.', $flutter_domain); ?> </p></div> <?php } } ?> <form action="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('submit-edit-custom-field') . "&custom-group-id={$customGroupID}"; ?> " method="post" id="edit-custom-field-form" onsubmit="return checkEmpty();"> <input type="hidden" name="custom-field-id" value="<?php echo $custom_field->id; ?> "> <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> <tbody> <tr valign="top"> <th scope="row"><?php _e('Name', $flutter_domain); ?> :</th> <td><input name="custom-field-name" id="custom-field-name" size="40" type="text" value="<?php echo htmlspecialchars($custom_field->name); ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Label', $flutter_domain); ?> :</th> <td><input name="custom-field-description" id="custom-field-description" size="40" type="text" value="<?php echo htmlspecialchars($custom_field->description); ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Can be duplicated', $flutter_domain); ?> :</th> <td><input name="custom-field-duplicate" id="custom-field-duplicate" type="checkbox" value="1" <?php echo $custom_field->duplicate == 0 ? "" : "checked"; ?> /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Order', $flutter_domain); ?> :</th> <td> <input name="custom-field-order" id="custom-field-order" size="2" type="text" value="<?php echo $custom_field->display_order; ?> " /> </td> </tr> <?php if (in_array($custom_field->type_id, array($FIELD_TYPES['textbox'], $FIELD_TYPES['multiline_textbox'], $FIELD_TYPES['dropdown_list'], $FIELD_TYPES['listbox'], $FIELD_TYPES['file'], $FIELD_TYPES['image'], $FIELD_TYPES['audio']))) { ?> <tr valign="top"> <th scope="row"><?php _e('Required', $flutter_domain); ?> :</th> <td> <select name="custom-field-required" id="custom-field-required"> <option value="0" <?php echo $custom_field->required_field == 0 ? 'selected="selected"' : ''; ?> ><?php _e('Not Required - can be empty', $flutter_domain); ?> </option> <option value="1" <?php echo $custom_field->required_field == 1 ? 'selected="selected"' : ''; ?> ><?php _e('Required - can not be empty', $flutter_domain); ?> </option> </select> </td> </tr> <?php } ?> <?php if (in_array($custom_field->type, array('Textbox', 'Listbox'))) { ?> <tr valign="top"> <th scope="row"><?php _e('Size', $flutter_domain); ?> :</th> <td><input type="text" name="custom-field-size" id="custom-field-size" size="2" value="<?php echo $custom_field->properties['size']; ?> " /></td> </tr> <?php } ?> <?php if (in_array($custom_field->type, array('Multiline Textbox'))) { ?> <tr valign="top"> <th scope="row"><?php _e('Height', $flutter_domain); ?> :</th> <td><input type="text" name="custom-field-height" id="custom-field-height" size="2" value="<?php echo $custom_field->properties['height']; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Width', $flutter_domain); ?> :</th> <td><input type="text" name="custom-field-width" id="custom-field-width" size="2" value="<?php echo $custom_field->properties['width']; ?> " /></td> </tr> <?php } ?> <?php if (in_array($custom_field->type, array('Date'))) { ?> <tr valign="top"> <th scope="row"><?php _e('Format', $flutter_domain); ?> :</th> <td> <select name="custom-field-date-format" id="custom-field-date-format"> <option value="m/d/Y" <?php if ($custom_field->properties['format'] == "m/d/Y") { echo " selected "; } ?> >4/20/2008</option> <option value="l, F d, Y" <?php if ($custom_field->properties['format'] == "l, F d, Y") { echo " selected "; } ?> >Sunday, April 20, 2008</option> <option value="F d, Y" <?php if ($custom_field->properties['format'] == "F d, Y") { echo " selected "; } ?> >April 20, 2008</option> <option value="m/d/y" <?php if ($custom_field->properties['format'] == "m/d/y") { echo " selected "; } ?> >4/20/08</option> <option value="Y-d-m" <?php if ($custom_field->properties['format'] == "Y-m-d") { echo " selected "; } ?> >2008-04-20</option> <option value="d-M-y" <?php if ($custom_field->properties['format'] == "d-M-y") { echo " selected "; } ?> >20-Apr-08</option> <option value="m.d.Y" <?php if ($custom_field->properties['format'] == "m.d.Y") { echo " selected "; } ?> >4.20.2008</option> <option value="m.d.y" <?php if ($custom_field->properties['format'] == "m.d.y") { echo " selected "; } ?> >4.20.08</option> </select> </td> </tr> <?php } ?> <?php if (in_array($custom_field->type, array('Slider'))) { ?> <tr valign="top"> <th scope="row"><?php echo _e('Value min', $flutter_domain); ?> :</th> <td><input type="text" name="custom-field-slider-min" id="custom-field-slider-min" size="2" value="<?php echo $custom_field->properties['min']; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php echo _e('Value max', $flutter_domain); ?> :</th> <td><input type="text" name="custom-field-slider-max" id="custom-field-slider-max" size="2" value="<?php echo $custom_field->properties['max']; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php echo _e('Stepping', $flutter_domain); ?> :</th> <td><input type="text" name="custom-field-slider-step" id="custom-field-slider-step" size="2" value="<?php echo $custom_field->properties['step']; ?> " /></td> </tr> <?php } ?> <?php if ($custom_field->has_options == "true") { $options = implode("\n", (array) $custom_field->options); ?> <tr valign="top"> <th scope="row"><?php _e('Options', $flutter_domain); ?> :</th> <td> <textarea name="custom-field-options" id="custom-field-options" rows="2" cols="38"><?php echo htmlspecialchars($options); ?> </textarea><br /> <em><?php _e('Separate each option with a newline.', $flutter_domain); ?> </em> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Default Value', $flutter_domain); ?> :</th> <td> <?php $default_value = implode("\n", (array) $custom_field->default_value); if ($custom_field->allow_multiple_values == "true") { ?> <textarea name="custom-field-default-value" id="custom-field-default-value" rows="2" cols="38"><?php echo htmlspecialchars($default_value); ?> </textarea><br /> <em><?php _e('Separate each value with a newline.', $flutter_domain); ?> </em> <?php } else { ?> <input type="text" name="custom-field-default-value" id="custom-field-default-value" size="25" value="<?php echo htmlspecialchars($default_value); ?> " /> <?php } ?> </td> </tr> <?php } ?> <tr valign="top"> <th scope="row"><?php _e('Type', $flutter_domain); ?> :</th> <td> <!-- START :: Javascript for Image/Photo' Css Class --> <script type="text/javascript" language="javascript"> submitForm = false; function fun(name) { if(name == "Image") { document.getElementById('divCSS').style.display = 'inline'; document.getElementById('divLbl').style.display = 'inline'; document.getElementById('lblHeight').style.display = 'inline'; document.getElementById('txtHeight').style.display = 'inline'; document.getElementById('lblWidth').style.display = 'inline'; document.getElementById('txtWidth').style.display = 'inline'; } else { document.getElementById('divCSS').style.display = 'none'; document.getElementById('divLbl').style.display = 'none'; document.getElementById('lblHeight').style.display = 'none'; document.getElementById('txtHeight').style.display = 'none'; document.getElementById('lblWidth').style.display = 'none'; document.getElementById('txtWidth').style.display = 'none'; } } function checkEmpty() { if (submitForm && (document.getElementById('custom-field-name').value == "" || document.getElementById('custom-field-description').value == "")){ alert("<?php _e('Please fill in the name and the label of the field', $flutter_domain); ?> "); return false; } return true; } </script> <!-- END :: Javascript for Image/Photo' Css Class --> <?php $field_types = RCCWP_CustomField::GetCustomFieldTypes(); foreach ($field_types as $field) { $checked = $field->name == $custom_field->type ? 'checked="checked"' : ''; ?> <label><input name="custom-field-type" value="<?php echo $field->id; ?> " type="radio" <?php echo $checked; ?> onclick='fun("<?php echo $field->name; ?> ");'/> <?php echo $field->name; ?> </label><br /> <?php } ?> </td> </tr> <!-- START :: For Image/Photo' Css --> <?php $isDisplay = $custom_field->type == "Image" ? 'display:inline;' : 'display:none;'; ?> <?php $size = explode("&", $custom_field->properties['params']); if (isset($size[3])) { $c = $size[3]; } if (substr($size[1], 0, 1) == "h") { $h = substr($size[1], 2); } elseif (substr($size[1], 0, 1) == "w") { $w = substr($size[1], 2); } if (substr($size[2], 0, 1) == "h") { $h = substr($size[2], 2); } elseif (substr($size[2], 0, 1) == "w") { $w = substr($size[2], 2); } $cssVlaue = $custom_field->CSS; ?> <tr valign="top"> <th scope="row"><span id="lblHeight" style="<?php echo $isDisplay; ?> "><?php _e('Max Height', $flutter_domain); ?> :</span></th> <td><span id="txtHeight" style="<?php echo $isDisplay; ?> "><input type="text" name="custom-field-photo-height" id="custom-field-photo-height" size="3" value="<?php echo $h; ?> " /></span></td> </tr> <tr valign="top"> <th scope="row"><span id="lblWidth" style="<?php echo $isDisplay; ?> "><?php _e('Max Width', $flutter_domain); ?> :</span></th> <td><span id="txtWidth" style="<?php echo $isDisplay; ?> "><input type="text" name="custom-field-photo-width" id="custom-field-photo-width" size="3" value="<?php echo $w; ?> " /></span></td> </tr> <tr valign="top"> <th scope="row"><span id="lblWidth" style="<?php echo $isDisplay; ?> "><?php _e('Custom', $flutter_domain); ?> :</span></th> <td><span id="txtWidth" style="<?php echo $isDisplay; ?> "><input type="text" name="custom-field-custom-params" id="custom-field-custom-params" value="<?php echo $c; ?> " /></span> </td> </tr> <tr valign="top"> <th scope="row"><div id="divLbl" style="<?php echo $isDisplay; ?> "><?php _e('Css Class', $flutter_domain); ?> :</div></th> <td> <div id="divCSS" style="<?php echo $isDisplay; ?> "> <input name="custom-field-css" id="custom-field-css" size="40" type="text" value="<?php echo $cssVlaue; ?> " /> </div> </td> </tr> <!-- END :: For Image/Photo' Css --> </tbody> </table> <input name="flutter_action" type="hidden" value="submit-edit-custom-field" /> <p class="submit" > <a style="color:black" href="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field') . "&custom-group-id={$customGroupID}"; ?> " class="button"><?php _e('Cancel', $flutter_domain); ?> </a> <input type="submit" id="submit-edit-custom-field" value="<?php _e('Update', $flutter_domain); ?> " onclick="submitForm=true;" /> </p> </form> </div> <?php }
function Main() { require_once 'RC_Format.php'; global $CUSTOM_WRITE_PANEL; wp_enqueue_script('jquery-ui-sortable'); if (isset($_POST['edit-with-no-custom-write-panel'])) { $type = RCCWP_Post::GetCustomWritePanel(); if (is_object($type)) { $ptype = $type->type; } else { $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post'; } wp_redirect($ptype . '.php?action=edit&post=' . $_POST['post-id'] . '&no-custom-write-panel'); } else { if (isset($_POST['edit-with-custom-write-panel']) && isset($_POST['custom-write-panel-id']) && (int) $_POST['custom-write-panel-id'] > 0) { $type = RCCWP_Post::GetCustomWritePanel(); if (is_object($type)) { $ptype = $type->type; } else { $ptype = strpos($_SERVER['REQUEST_URI'], 'page.php') !== FALSE ? 'page' : 'post'; } wp_redirect($type->type . '.php?action=edit&post=' . $_POST['post-id'] . '&custom-write-panel-id=' . $_POST['custom-write-panel-id']); } } if (empty($_REQUEST['mf_action'])) { $currentAction = ""; } else { $currentAction = $_REQUEST['mf_action']; } switch ($currentAction) { // ------------ Write Panels case 'finish-create-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; $default_theme_page = NULL; if ($_POST['radPostPage'] == 'page') { $default_theme_page = $_POST['page_template']; } $customWritePanelId = RCCWP_CustomWritePanel::Create($_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page); wp_redirect(RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('view-custom-write-panel', $customWritePanelId)); break; case 'submit-edit-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; $default_theme_page = NULL; if ($_POST['radPostPage'] == 'page') { $default_theme_page = $_POST['page_template']; } RCCWP_CustomWritePanel::Update($_POST['custom-write-panel-id'], $_POST['custom-write-panel-name'], $_POST['custom-write-panel-description'], $_POST['custom-write-panel-standard-fields'], $_POST['custom-write-panel-categories'], $_POST['custom-write-panel-order'], FALSE, true, $_POST['single'], $default_theme_page); RCCWP_CustomWritePanel::AssignToRole($_POST['custom-write-panel-id'], 'administrator'); break; case 'export-custom-write-panel': require_once 'RCCWP_CustomWritePanel.php'; $panelID = $_REQUEST['custom-write-panel-id']; $writePanel = RCCWP_CustomWritePanel::Get($panelID); $exportedFilename = $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $writePanel->name . '.pnl'; RCCWP_CustomWritePanel::Export($panelID, $exportedFilename); // send file in header header('Content-type: binary'); header('Content-Disposition: attachment; filename="' . $writePanel->name . '.pnl"'); readfile($exportedFilename); unlink($exportedFilename); exit; break; case 'delete-custom-write-panel': include_once 'RCCWP_CustomWritePanel.php'; RCCWP_CustomWritePanel::Delete($_GET['custom-write-panel-id']); break; // ------------ Groups // ------------ Groups case 'finish-create-custom-group': include_once 'RCCWP_CustomGroup.php'; $customGroupId = RCCWP_CustomGroup::Create($_POST['custom-write-panel-id'], $_POST['custom-group-name'], $_POST['custom-group-duplicate'], $_POST['custom-group-at_right']); break; case 'delete-custom-group': include_once 'RCCWP_CustomGroup.php'; $customGroup = RCCWP_CustomGroup::Get((int) $_REQUEST['custom-group-id']); RCCWP_CustomGroup::Delete($_GET['custom-group-id']); break; case 'submit-edit-custom-group': include_once 'RCCWP_CustomGroup.php'; RCCWP_CustomGroup::Update($_REQUEST['custom-group-id'], $_POST['custom-group-name'], $_POST['custom-group-duplicate'], $_POST['custom-group-at_right']); break; // ------------ Fields // ------------ Fields case 'copy-custom-field': include_once 'RCCWP_CustomField.php'; $fieldToCopy = RCCWP_CustomField::Get($_REQUEST['custom-field-id']); if (RCCWP_Processor::CheckFieldName($fieldToCopy->name, $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } RCCWP_CustomField::Create($_REQUEST['custom-group-id'], $fieldToCopy->name, $fieldToCopy->description, $fieldToCopy->display_order, $fieldToCopy->required_field, $fieldToCopy->type_id, $fieldToCopy->options, $fieldToCopy->default_value, $fieldToCopy->properties, $fieldToCopy->duplicate, $fieldToCopy->helptext); case 'continue-create-custom-field': if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } break; case 'finish-create-custom-field': include_once 'RCCWP_CustomField.php'; if (RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('create-custom-field') . '&custom-group-id=' . $_REQUEST['custom-group-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_REQUEST['custom-field-type']); if ($current_field->has_properties) { $custom_field_properties = array(); if (in_array($current_field->name, array('Textbox', 'Listbox'))) { $custom_field_properties['size'] = $_POST['custom-field-size']; } else { if (in_array($current_field->name, array('Multiline Textbox'))) { $custom_field_properties['height'] = $_POST['custom-field-height']; $custom_field_properties['width'] = $_POST['custom-field-width']; } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Image'))) { $params = ''; if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) { $params .= '&h=' . $_POST['custom-field-photo-height']; } if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) { $params .= '&w=' . $_POST['custom-field-photo-width']; } if ($_POST['custom-field-custom-params'] != '') { $params .= '&' . $_POST['custom-field-custom-params']; } if ($params) { $custom_field_properties['params'] = $params; } } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Slider'))) { $custom_field_properties['max'] = $_POST['custom-field-slider-max']; $custom_field_properties['min'] = $_POST['custom-field-slider-min']; $custom_field_properties['step'] = $_POST['custom-field-slider-step']; } else { if (in_array($current_field->name, array('Related Type'))) { $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id']; } } } } } } } } RCCWP_CustomField::Create($_POST['custom-group-id'], $_POST['custom-field-name'], $_POST['custom-field-description'], $_POST['custom-field-order'], $_POST['custom-field-required'], $_POST['custom-field-type'], $_POST['custom-field-options'], $_POST['custom-field-default-value'], $custom_field_properties, $_POST['custom-field-duplicate'], $_POST['custom-field-helptext']); break; case 'submit-edit-custom-field': include_once 'RCCWP_CustomField.php'; $current_field_obj = RCCWP_CustomField::Get($_POST['custom-field-id']); if ($_POST['custom-field-name'] != $current_field_obj->name && RCCWP_Processor::CheckFieldName($_POST['custom-field-name'], $_REQUEST['custom-write-panel-id'])) { $newURL = RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('edit-custom-field') . '&custom-field-id=' . $_POST['custom-field-id'] . '&err_msg=-1'; wp_redirect($newURL); exit; } $current_field = RCCWP_CustomField::GetCustomFieldTypes((int) $_POST['custom-field-type']); if ($current_field->has_properties) { $custom_field_properties = array(); if (in_array($current_field->name, array('Textbox', 'Listbox'))) { $custom_field_properties['size'] = $_POST['custom-field-size']; } else { if (in_array($current_field->name, array('Multiline Textbox'))) { $custom_field_properties['height'] = $_POST['custom-field-height']; $custom_field_properties['width'] = $_POST['custom-field-width']; } else { if (in_array($current_field->name, array('Image'))) { $params = ''; if ($_POST['custom-field-photo-height'] != '' && is_numeric($_POST['custom-field-photo-height'])) { $params = '&h=' . $_POST['custom-field-photo-height']; } if ($_POST['custom-field-photo-width'] != '' && is_numeric($_POST['custom-field-photo-width'])) { $params .= '&w=' . $_POST['custom-field-photo-width']; } if ($_POST['custom-field-custom-params'] != '') { $params .= '&' . $_POST['custom-field-custom-params']; } if ($params) { $custom_field_properties['params'] = $params; } } else { if (in_array($current_field->name, array('Date'))) { $custom_field_properties['format'] = $_POST['custom-field-date-format']; } else { if (in_array($current_field->name, array('Slider'))) { $custom_field_properties['max'] = $_POST['custom-field-slider-max']; $custom_field_properties['min'] = $_POST['custom-field-slider-min']; $custom_field_properties['step'] = $_POST['custom-field-slider-step']; } else { if (in_array($current_field->name, array('Related Type'))) { $custom_field_properties['panel_id'] = $_POST['custom-field-related-type-panel-id']; } } } } } } } RCCWP_CustomField::Update($_POST['custom-field-id'], $_POST['custom-field-name'], $_POST['custom-field-description'], $_POST['custom-field-order'], $_POST['custom-field-required'], $_POST['custom-field-type'], $_POST['custom-field-options'], $_POST['custom-field-default-value'], $custom_field_properties, $_POST['custom-field-duplicate'], $_POST['custom-field-helptext']); break; case 'delete-custom-field': include_once 'RCCWP_CustomField.php'; if (isset($_REQUEST['custom-group-id']) && !empty($_REQUEST['custom-group-id'])) { $customGroupId = (int) $_REQUEST['custom-group-id']; } $customGroup = RCCWP_CustomGroup::Get($customGroupId); RCCWP_CustomField::Delete($_REQUEST['custom-field-id']); break; default: if (RCCWP_Application::InWritePostPanel()) { include_once 'RCCWP_Menu.php'; include_once 'RCCWP_WritePostPage.php'; $CUSTOM_WRITE_PANEL = RCCWP_Post::GetCustomWritePanel(); if (isset($CUSTOM_WRITE_PANEL) && $CUSTOM_WRITE_PANEL > 0) { ob_start(array('RCCWP_WritePostPage', 'ApplyCustomWritePanelAssignedCategories')); add_action('admin_head', array('RCCWP_WritePostPage', 'CustomFieldsCSS')); //adding javascripts files for the custom fields add_action('admin_print_scripts', array('RCCWP_WritePostPage', 'CustomFieldsJavascript')); add_action('admin_head', array('RCCWP_WritePostPage', 'ApplyCustomWritePanelHeader')); add_action('admin_menu', array('RCCWP_WritePostPage', 'CustomFieldCollectionInterface')); } else { if (!isset($_REQUEST['no-custom-write-panel']) && isset($_REQUEST['post'])) { include_once 'RCCWP_Options.php'; $promptEditingPost = RCCWP_Options::Get('prompt-editing-post'); if ($promptEditingPost == 1) { wp_redirect('?page=' . urlencode(MF_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'RCCWP_Menu.php') . '&assign-custom-write-panel=' . (int) $_GET['post']); } } } } else { if (isset($_POST['update-custom-write-panel-options'])) { if ($_POST['uninstall-custom-write-panel'] == 'uninstall') { RCCWP_Application::Uninstall(); wp_redirect('options-general.php'); } else { include_once 'RCCWP_Options.php'; $options['hide-write-post'] = $_POST['hide-write-post']; $options['hide-write-page'] = $_POST['hide-write-page']; $options['hide-visual-editor'] = $_POST['hide-visual-editor']; $options['prompt-editing-post'] = $_POST['prompt-editing-post']; $options['assign-to-role'] = $_POST['assign-to-role']; $options['use-snipshot'] = $_POST['use-snipshot']; $options['enable-editnplace'] = $_POST['enable-editnplace']; $options['eip-highlight-color'] = $_POST['eip-highlight-color']; $options['enable-swfupload'] = $_POST['enable-swfupload']; $options['enable-browserupload'] = $_POST['enable-browserupload']; $options['default-custom-write-panel'] = $_POST['default-custom-write-panel']; $options['enable-HTMLPurifier'] = $_POST['enable-HTMLPurifier']; $options['tidy-level'] = $_POST['tidy-level']; $options['canvas_show_instructions'] = $_POST['canvas_show_instructions']; $options['canvas_show_zone_name'] = $_POST['canvas_show_zone_name']; $options['canvas_show'] = $_POST['canvas_show']; $options['ink_show'] = $_POST['ink_show']; $options['hide-non-standart-content'] = $_POST['hide-non-standart-content']; $options['condense-menu'] = $_POST['condense-menu']; RCCWP_Options::Update($options); $EnP = RCCWP_Application::create_EditnPlace_css(TRUE); } } } } }
function Edit() { global $FIELD_TYPES; global $mf_domain; $custom_field = RCCWP_CustomField::Get((int) $_GET['custom-field-id']); $customGroupID = $custom_field->group_id; if (isset($customGroupID)) { $group = RCCWP_CustomGroup::Get($customGroupID); ?> <script type="text/javascript"> var mf_create_field = false; var mf_group_info = { 'name' : '<?php echo stripslashes($group->name); ?> ', 'safe_name' : '<?php echo sanitize_title_with_dashes($group->name); ?> ', 'singular_safe_name' : '<?php echo sanitize_title_with_dashes(Inflect::singularize($group->name)); ?> ' }; </script> <?php } if (in_array($custom_field->type, array('Image'))) { $cssVlaue = $custom_field->CSS; } ?> <div class="wrap"> <h2><?php _e('Edit Custom Field', $mf_domain); ?> - <em><?php echo $custom_field->description; ?> </em> <?php if ($group && $group->name != "__default") { _e("In Group", $mf_domain); echo " <em>" . $group->name . "</em>"; } ?> </h2> <br class="clear" /> <?php if (isset($_GET['err_msg'])) { switch ($_GET['err_msg']) { case -1: ?> <div class="error"><p> <?php _e('A field with the same name already exists in this write panel. Please choose a different name.', $mf_domain); ?> </p></div> <?php } } ?> <form action="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('submit-edit-custom-field') . "&custom-group-id={$customGroupID}"; ?> " method="post" id="edit-custom-field-form" onsubmit="return checkEmpty();"> <input type="hidden" name="custom-field-id" value="<?php echo $custom_field->id; ?> "> <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6"> <tbody> <tr valign="top"> <th scope="row"><?php _e('Label', $mf_domain); ?> :</th> <td><input name="custom-field-description" id="custom-field-description" size="40" type="text" value="<?php echo htmlspecialchars($custom_field->description); ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Name', $mf_domain); ?> :</th> <td><input name="custom-field-name" id="custom-field-name" size="40" type="text" value="<?php echo htmlspecialchars($custom_field->name); ?> " /><button id="bt-custom-field-name-suggest" class="button">Suggest</button></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Help text', $mf_domain); ?> :</th> <td><input name="custom-field-helptext" id="custom-field-helptext" size="40" type="text" value="<?php echo htmlspecialchars($custom_field->help_text); ?> " /><br/><small><?php _e('If set, this will be displayed in a tooltip next to the field label', $mf_domain); ?> </small></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Can be duplicated', $mf_domain); ?> :</th> <td><input name="custom-field-duplicate" id="custom-field-duplicate" type="checkbox" value="1" <?php echo $custom_field->duplicate == 0 ? "" : "checked"; ?> /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Order', $mf_domain); ?> :</th> <td> <input name="custom-field-order" id="custom-field-order" size="2" type="text" value="<?php echo $custom_field->display_order; ?> " /> </td> </tr> <?php if (in_array($custom_field->type_id, array($FIELD_TYPES['textbox'], $FIELD_TYPES['multiline_textbox'], $FIELD_TYPES['checkbox'], $FIELD_TYPES['checkbox_list'], $FIELD_TYPES['radiobutton_list'], $FIELD_TYPES['dropdown_list'], $FIELD_TYPES['listbox'], $FIELD_TYPES['file'], $FIELD_TYPES['image'], $FIELD_TYPES['audio'], $FIELD_TYPES['related_type'], $FIELD_TYPES['Image (Upload Media)'], $FIELD_TYPES['markdown_textbox']))) { ?> <tr valign="top"> <th scope="row"><?php _e('Required', $mf_domain); ?> :</th> <td> <select name="custom-field-required" id="custom-field-required"> <option value="0" <?php echo $custom_field->required_field == 0 ? 'selected="selected"' : ''; ?> ><?php _e('Not Required - can be empty', $mf_domain); ?> </option> <option value="1" <?php echo $custom_field->required_field == 1 ? 'selected="selected"' : ''; ?> ><?php _e('Required - can not be empty', $mf_domain); ?> </option> </select> </td> </tr> <?php } ?> <?php if (in_array($custom_field->type, array('Textbox', 'Listbox'))) { ?> <tr valign="top"> <th scope="row"><?php _e('Size', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-size" id="custom-field-size" size="2" value="<?php echo $custom_field->properties['size']; ?> " /></td> </tr> <?php } ?> <?php if (in_array($custom_field->type, array('Multiline Textbox'))) { ?> <tr valign="top"> <th scope="row"><?php _e('Height', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-height" id="custom-field-height" size="2" value="<?php echo $custom_field->properties['height']; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Width', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-width" id="custom-field-width" size="2" value="<?php echo $custom_field->properties['width']; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Hide Visual Editor for this field', $mf_domain); ?> :</th> <td><input name="hide-visual-editor" id="hide-visual-editor" value="1" type="checkbox" <?php echo $custom_field->properties['hide-visual-editor'] == 0 ? "" : "checked"; ?> ></td> </tr> <?php } ?> <?php if (in_array($custom_field->type_id, array($FIELD_TYPES['textbox'], $FIELD_TYPES['multiline_textbox']))) { ?> <tr valign="top"> <th scope="row"><?php _e('Evaluate Max Length', $mf_domain); ?> :</th> <td><input name="strict-max-length" id="strict-max-length" value="1" type="checkbox" <?php echo $custom_field->properties['strict-max-length'] == 0 ? "" : "checked"; ?> ><br/><small><?php _e('If set, Hide Visual Editor for this field', $mf_domain); ?> </small></td> </tr> <?php } ?> <?php if (in_array($custom_field->type, array('Date'))) { ?> <tr valign="top"> <th scope="row"><?php _e('Format', $mf_domain); ?> :</th> <td> <select name="custom-field-date-format" id="custom-field-date-format"> <option value="m/d/Y" <?php if ($custom_field->properties['format'] == "m/d/Y") { echo " selected "; } ?> >4/20/2008</option> <option value="l, F d, Y" <?php if ($custom_field->properties['format'] == "l, F d, Y") { echo " selected "; } ?> >Sunday, April 20, 2008</option> <option value="F d, Y" <?php if ($custom_field->properties['format'] == "F d, Y") { echo " selected "; } ?> >April 20, 2008</option> <option value="m/d/y" <?php if ($custom_field->properties['format'] == "m/d/y") { echo " selected "; } ?> >4/20/08</option> <option value="Y-m-d" <?php if ($custom_field->properties['format'] == "Y-m-d") { echo " selected "; } ?> >2008-04-20</option> <option value="d-M-y" <?php if ($custom_field->properties['format'] == "d-M-y") { echo " selected "; } ?> >20-Apr-08</option> <option value="m.d.Y" <?php if ($custom_field->properties['format'] == "m.d.Y") { echo " selected "; } ?> >4.20.2008</option> <option value="m.d.y" <?php if ($custom_field->properties['format'] == "m.d.y") { echo " selected "; } ?> >4.20.08</option> </select> </td> </tr> <?php } ?> <?php if (in_array($custom_field->type, array('Slider'))) { ?> <tr valign="top"> <th scope="row"><?php echo _e('Value min', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-slider-min" id="custom-field-slider-min" size="2" value="<?php echo $custom_field->properties['min']; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php echo _e('Value max', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-slider-max" id="custom-field-slider-max" size="2" value="<?php echo $custom_field->properties['max']; ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php echo _e('Stepping', $mf_domain); ?> :</th> <td><input type="text" name="custom-field-slider-step" id="custom-field-slider-step" size="2" value="<?php echo $custom_field->properties['step']; ?> " /></td> </tr> <?php } ?> <?php //eeble if (in_array($custom_field->type, array('Related Type'))) { $customWritePanels = RCCWP_CustomWritePanel::GetCustomWritePanels(); ?> <tr valign="top"> <th scope="row"><?php _e('Related Type Panel', $mf_domain); ?> :</th> <td><select name="custom-field-related-type-panel-id" id="custom-field-related-type-panel-id"> <option value="-7" <?php if ($custom_field->properties['panel_id'] == -7) { echo 'selected'; } ?> >All Categories</option> <option value="-6" <?php if ($custom_field->properties['panel_id'] == -6) { echo 'selected'; } ?> >All Posts and Pages</option> <option value="-5" <?php if ($custom_field->properties['panel_id'] == -5) { echo 'selected'; } ?> >All Posts and Pages with Write Panel</option> <option value="-4" <?php if ($custom_field->properties['panel_id'] == -4) { echo 'selected'; } ?> >All Post</option> <option value="-3" <?php if ($custom_field->properties['panel_id'] == -3) { echo 'selected'; } ?> >All Page</option> <option value="-2" <?php if ($custom_field->properties['panel_id'] == -2) { echo 'selected'; } ?> >All Post with Write Panel</option> <option value="-1" <?php if ($custom_field->properties['panel_id'] == -1) { echo 'selected'; } ?> >All Page with Write Panel</option> <?php foreach ($customWritePanels as $panel) { ?> <option value="<?php echo $panel->id; ?> " <?php if ($custom_field->properties['panel_id'] == $panel->id) { echo 'selected'; } ?> ><?php echo $panel->name; ?> </option> <?php } ?> </select></td> </tr> <?php } ?> <?php if ($custom_field->has_options == "true") { $options = implode("\n", (array) $custom_field->options); ?> <tr valign="top"> <th scope="row"><?php _e('Options', $mf_domain); ?> :</th> <td> <textarea name="custom-field-options" id="custom-field-options" rows="2" cols="38"><?php echo htmlspecialchars($options); ?> </textarea><br /> <em><?php _e('Separate each option with a newline.', $mf_domain); ?> </em> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Default Value', $mf_domain); ?> :</th> <td> <?php $default_value = implode("\n", (array) $custom_field->default_value); if ($custom_field->allow_multiple_values == "true") { ?> <textarea name="custom-field-default-value" id="custom-field-default-value" rows="2" cols="38"><?php echo htmlspecialchars($default_value); ?> </textarea><br /> <em><?php _e('Separate each value with a newline.', $mf_domain); ?> </em> <?php } else { ?> <input type="text" name="custom-field-default-value" id="custom-field-default-value" size="25" value="<?php echo htmlspecialchars($default_value); ?> " /> <?php } ?> </td> </tr> <?php } ?> <tr valign="top"> <th scope="row"><?php _e('Type', $mf_domain); ?> :</th> <td> <!-- START :: Javascript for Image/Photo' Css Class --> <script type="text/javascript" language="javascript"> submitForm = false; function fun(name) { if(name == "Image") { document.getElementById('divCSS').style.display = 'inline'; document.getElementById('divLbl').style.display = 'inline'; document.getElementById('lblHeight').style.display = 'inline'; document.getElementById('txtHeight').style.display = 'inline'; document.getElementById('lblWidth').style.display = 'inline'; document.getElementById('txtWidth').style.display = 'inline'; } else { document.getElementById('divCSS').style.display = 'none'; document.getElementById('divLbl').style.display = 'none'; document.getElementById('lblHeight').style.display = 'none'; document.getElementById('txtHeight').style.display = 'none'; document.getElementById('lblWidth').style.display = 'none'; document.getElementById('txtWidth').style.display = 'none'; } } function checkEmpty() { if (submitForm && (document.getElementById('custom-field-name').value == "" || document.getElementById('custom-field-description').value == "")){ alert("<?php _e('Please fill in the name and the label of the field', $mf_domain); ?> "); return false; } return true; } </script> <!-- END :: Javascript for Image/Photo' Css Class --> <?php $field_types = RCCWP_CustomField::GetCustomFieldTypes(); foreach ($field_types as $field) { $checked = $field->name == $custom_field->type ? 'checked="checked"' : ''; ?> <label><input name="custom-field-type" value="<?php echo $field->id; ?> " type="radio" <?php echo $checked; ?> onclick='fun("<?php echo $field->name; ?> ");'/> <?php echo $field->name; ?> </label><br /> <?php } ?> </td> </tr> <!-- START :: For Image/Photo' Css --> <?php if ($custom_field->type == "Image" || $custom_field->type == "Image (Upload Media)") { $h = $w = $c = NULL; if ($custom_field->type == "Image") { $isDisplay = $custom_field->type == "Image" ? 'display:inline;' : 'display:none;'; } if ($custom_field->type == "Image (Upload Media)") { $isDisplay = $custom_field->type == "Image (Upload Media)" ? 'display:inline;' : 'display:none;'; } if (isset($custom_field->properties['params'])) { preg_match('/w\\=[0-9]+/', $custom_field->properties['params'], $match_w); if ($match_w) { $w = str_replace("w=", '', $match_w[0]); $custom_field->properties['params'] = str_replace("&" . $match_w[0], "", $custom_field->properties['params']); } preg_match('/h\\=[0-9]+/', $custom_field->properties['params'], $match_h); if ($match_h) { $h = str_replace("h=", '', $match_h[0]); $custom_field->properties['params'] = str_replace("&" . $match_h[0], "", $custom_field->properties['params']); } if ($custom_field->properties['params']) { if (substr($custom_field->properties['params'], 0, 1) == "&") { $c = substr($custom_field->properties['params'], 1); } } } $cssVlaue = $custom_field->CSS; ?> <tr valign="top"> <th scope="row"><span id="lblHeight" style="<?php echo $isDisplay; ?> "><?php _e('Max Height', $mf_domain); ?> :</span></th> <td><span id="txtHeight" style="<?php echo $isDisplay; ?> "><input type="text" name="custom-field-photo-height" id="custom-field-photo-height" size="3" value="<?php echo $h; ?> " /></span></td> </tr> <tr valign="top"> <th scope="row"><span id="lblWidth" style="<?php echo $isDisplay; ?> "><?php _e('Max Width', $mf_domain); ?> :</span></th> <td><span id="txtWidth" style="<?php echo $isDisplay; ?> "><input type="text" name="custom-field-photo-width" id="custom-field-photo-width" size="3" value="<?php echo $w; ?> " /></span></td> </tr> <tr valign="top"> <th scope="row"><span id="lblWidth" style="<?php echo $isDisplay; ?> "><?php _e('Custom', $mf_domain); ?> :</span></th> <td><span id="txtWidth" style="<?php echo $isDisplay; ?> "><input type="text" name="custom-field-custom-params" id="custom-field-custom-params" value="<?php echo $c; ?> " /></span> </td> </tr> <tr valign="top"> <th scope="row"><div id="divLbl" style="<?php echo $isDisplay; ?> "><?php _e('Css Class', $mf_domain); ?> :</div></th> <td> <div id="divCSS" style="<?php echo $isDisplay; ?> "> <input name="custom-field-css" id="custom-field-css" size="40" type="text" value="<?php echo $cssVlaue; ?> " /> </div> </td> </tr> <?php } ?> <!-- END :: For Image/Photo' Css --> </tbody> </table> <input name="mf_action" type="hidden" value="submit-edit-custom-field" /> <p class="submit" > <a style="color:black" href="<?php echo RCCWP_ManagementPage::GetCustomWritePanelGenericUrl('cancel-create-custom-field') . "&custom-group-id={$customGroupID}"; ?> " class="button"><?php _e('Cancel', $mf_domain); ?> </a> <input type="submit" id="submit-edit-custom-field" value="<?php _e('Update', $mf_domain); ?> " onclick="submitForm=true;" /> </p> </form> </div> <?php }