GetMetaID() public static method

@param integer $postId Post id
public static GetMetaID ( integer $postId, $customFieldName, integer $groupIndex = 1, integer $fieldIndex = 1 ) : integer
$postId integer
$groupIndex integer
$fieldIndex integer
return integer
Ejemplo n.º 1
0
/**
 * Get the value of an input field.
 *
 * @param string $fieldName
 * @param integer $groupIndex
 * @param integer $fieldIndex
 * @param boolean $readyForEIP if true and the field type is textbox or
 * 				multiline textbox, the resulting value will be wrapped
 * 				in a div that is ready for EIP. The default value is true
 * @return a string or array based on field type
 */
function get($fieldName, $groupIndex = 1, $fieldIndex = 1, $readyForEIP = true)
{
    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);
    $fieldMetaID = RCCWP_CustomField::GetMetaID($post->ID, $fieldName, $groupIndex, $fieldIndex);
    $results = GetProcessedFieldValue($fieldValues, $fieldType, $fieldObject->properties);
    //filter for multine line
    if ($fieldType == $FIELD_TYPES['multiline_textbox']) {
        $results = apply_filters('the_content', $results);
    }
    if ($fieldType == $FIELD_TYPES['image']) {
        $results = split('&', $results);
        $results = $results[0];
    }
    // Prepare fields for EIP
    include_once 'RCCWP_Options.php';
    $enableEditnplace = RCCWP_Options::Get('enable-editnplace');
    if ($readyForEIP && $enableEditnplace == 1 && current_user_can('edit_posts', $post->ID)) {
        switch ($fieldType) {
            case $FIELD_TYPES["textbox"]:
                if (!$results) {
                    $results = "&nbsp";
                }
                $results = "<div class='" . EIP_textbox($fieldMetaID) . "' >" . $results . "</div>";
                break;
            case $FIELD_TYPES["multiline_textbox"]:
                if (!$results) {
                    $results = "&nbsp";
                }
                $results = "<div class='" . EIP_mulittextbox($fieldMetaID) . "' >" . $results . "</div>";
                break;
        }
    }
    return $results;
}
Ejemplo n.º 2
0
 /**
  * Retrieves the value of a custom field for a specified post
  *
  * @param boolean $single
  * @param integer $postId
  * @param string $customFieldName
  * @param integer $groupIndex
  * @param integer $fieldIndex
  * @return a
  */
 function GetCustomFieldValues($single, $postId, $customFieldName, $groupIndex = 1, $fieldIndex = 1)
 {
     global $wpdb;
     $fieldMetaID = RCCWP_CustomField::GetMetaID($postId, $customFieldName, $groupIndex, $fieldIndex);
     // for backward compatability, if no accociated row was found, use old method
     if (!$fieldMetaID) {
         //$customFieldName =  $wpdb->get_var("SELECT name FROM ". RC_CWP_TABLE_GROUP_FIELDS .
         //									" WHERE id = '$customFieldId'");
         return get_post_meta($postId, $customFieldName, $single);
     }
     // Get meta value
     $mid = (int) $fieldMetaID;
     $meta = $wpdb->get_row("SELECT * FROM {$wpdb->postmeta} WHERE meta_id = '{$mid}'");
     if (!$single) {
         return unserialize($meta->meta_value);
     }
     return $meta->meta_value;
 }
Ejemplo n.º 3
0
 /**
  * Retrieves the value of a custom field for a specified post
  *
  * @param boolean $single
  * @param integer $postId
  * @param string $customFieldName
  * @param integer $groupIndex
  * @param integer $fieldIndex
  * @return mixed
  * @TODO review if is still necessary save the "backward compatibility"
  */
 function GetCustomFieldValues($single, $postId, $customFieldName, $groupIndex = 1, $fieldIndex = 1)
 {
     global $wpdb;
     $customFieldName = str_replace(" ", "_", $customFieldName);
     $fieldMetaID = RCCWP_CustomField::GetMetaID($postId, $customFieldName, $groupIndex, $fieldIndex);
     // for backward compatability, if no associated row was found, use old method
     if (!$fieldMetaID) {
         return get_post_meta($postId, $customFieldName, $single);
     }
     // Get meta value
     $mid = (int) $fieldMetaID;
     $meta = $wpdb->get_row("SELECT * FROM {$wpdb->postmeta} WHERE meta_id = '{$mid}'");
     if (!$single) {
         return unserialize($meta->meta_value);
     }
     return $meta->meta_value;
 }