Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../src/helpers
File: meta-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers;
[2] Fix | Delete
[3] Fix | Delete
use WPSEO_Meta;
[4] Fix | Delete
use WPSEO_Taxonomy_Meta;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* A helper object for meta.
[8] Fix | Delete
*/
[9] Fix | Delete
class Meta_Helper {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Get a custom post meta value.
[13] Fix | Delete
*
[14] Fix | Delete
* Returns the default value if the meta value has not been set.
[15] Fix | Delete
*
[16] Fix | Delete
* {@internal Unfortunately there isn't a filter available to hook into before returning
[17] Fix | Delete
* the results for get_post_meta(), get_post_custom() and the likes. That
[18] Fix | Delete
* would have been the preferred solution.}}
[19] Fix | Delete
*
[20] Fix | Delete
* @codeCoverageIgnore We have to write test when this method contains own code.
[21] Fix | Delete
*
[22] Fix | Delete
* @param string $key Internal key of the value to get (without prefix).
[23] Fix | Delete
* @param int $postid Post ID of the post to get the value for.
[24] Fix | Delete
*
[25] Fix | Delete
* @return string All 'normal' values returned from get_post_meta() are strings.
[26] Fix | Delete
* Objects and arrays are possible, but not used by this plugin
[27] Fix | Delete
* and therefore discarted (except when the special 'serialized' field def
[28] Fix | Delete
* value is set to true - only used by add-on plugins for now).
[29] Fix | Delete
* Will return the default value if no value was found.
[30] Fix | Delete
* Will return empty string if no default was found (not one of our keys) or
[31] Fix | Delete
* if the post does not exist.
[32] Fix | Delete
*/
[33] Fix | Delete
public function get_value( $key, $postid = 0 ) {
[34] Fix | Delete
return WPSEO_Meta::get_value( $key, $postid );
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Retrieve a taxonomy term's meta value(s).
[39] Fix | Delete
*
[40] Fix | Delete
* @param mixed $term Term to get the meta value for
[41] Fix | Delete
* either (string) term name, (int) term id or (object) term.
[42] Fix | Delete
* @param string $taxonomy Name of the taxonomy to which the term is attached.
[43] Fix | Delete
* @param string|null $meta Optional. Meta value to get (without prefix).
[44] Fix | Delete
*
[45] Fix | Delete
* @return mixed|bool Value for the $meta if one is given, might be the default.
[46] Fix | Delete
* If no meta is given, an array of all the meta data for the term.
[47] Fix | Delete
* False if the term does not exist or the $meta provided is invalid.
[48] Fix | Delete
*/
[49] Fix | Delete
public function get_term_value( $term, $taxonomy, $meta = null ) {
[50] Fix | Delete
return WPSEO_Taxonomy_Meta::get_term_meta( $term, $taxonomy, $meta );
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Set a custom post meta value.
[55] Fix | Delete
*
[56] Fix | Delete
* @param string $key Internal key of the value to set (without prefix).
[57] Fix | Delete
* @param mixed $meta_value The value to set the meta value to.
[58] Fix | Delete
* @param int $post_id Post ID of the post to set the value for.
[59] Fix | Delete
*
[60] Fix | Delete
* @return bool Whether the value was changed.
[61] Fix | Delete
*/
[62] Fix | Delete
public function set_value( $key, $meta_value, $post_id ) {
[63] Fix | Delete
return WPSEO_Meta::set_value( $key, $meta_value, $post_id );
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function