本文整理汇总了PHP中MS_Model_Membership::get_post_type方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Model_Membership::get_post_type方法的具体用法?PHP MS_Model_Membership::get_post_type怎么用?PHP MS_Model_Membership::get_post_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Model_Membership
的用法示例。
在下文中一共展示了MS_Model_Membership::get_post_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register_custom_post_types
/**
* Register plugin custom post types.
*
* @since 1.0.0
*/
public function register_custom_post_types()
{
do_action('ms_plugin_register_custom_post_types_before', $this);
$cpts = apply_filters('ms_plugin_register_custom_post_types', array(MS_Model_Membership::get_post_type() => MS_Model_Membership::get_register_post_type_args(), MS_Model_Relationship::get_post_type() => MS_Model_Relationship::get_register_post_type_args(), MS_Model_Invoice::get_post_type() => MS_Model_Invoice::get_register_post_type_args(), MS_Model_Communication::get_post_type() => MS_Model_Communication::get_register_post_type_args(), MS_Model_Event::get_post_type() => MS_Model_Event::get_register_post_type_args()));
foreach ($cpts as $cpt => $args) {
MS_Helper_Utility::register_post_type($cpt, $args);
}
}
示例2: cleanup_db
/**
* Completely whipe all Membership data from Database.
*
* Note: This function is not used currently...
*
* @since 1.0.0
*/
private static function cleanup_db()
{
global $wpdb;
$sql = array();
$trash_ids = array();
// Delete membership meta-data from users.
$users = MS_Model_Member::get_members();
foreach ($users as $user) {
$user->delete_all_membership_usermeta();
$user->save();
}
// Determine IDs of Membership Pages.
$page_types = MS_Model_Pages::get_page_types();
foreach ($page_types as $type => $name) {
$page_id = MS_Model_Pages::get_setting($type);
$trash_ids[] = $page_id;
}
/**
* Delete all plugin settings.
* Settings are saved by classes that extend MS_Model_option
*/
foreach (MS_Model_Gateway::get_gateways() as $option) {
$option->delete();
}
MS_Factory::load('MS_Model_Addon')->delete();
MS_Factory::load('MS_Model_Pages')->delete();
MS_Factory::load('MS_Model_Settings')->delete();
/**
* Delete transient data
* Transient data is saved by classed that extend MS_Model_Transient
*/
MS_Factory::load('MS_Model_Simulate')->delete();
/**
* Delete all plugin content.
* Content is saved by classes that extend MS_Model_CustomPostType
*/
$ms_posttypes = array(MS_Model_Communication::get_post_type(), MS_Model_Event::get_post_type(), MS_Model_Invoice::get_post_type(), MS_Model_Transactionlog::get_post_type(), MS_Model_Membership::get_post_type(), MS_Model_Relationship::get_post_type(), MS_Addon_Coupon_Model::get_post_type(), MS_Addon_Invitation_Model::get_post_type());
foreach ($ms_posttypes as $type) {
$sql[] = $wpdb->prepare("DELETE FROM {$wpdb->posts} WHERE post_type = %s;", $type);
}
// Remove orphaned post-metadata.
$sql[] = "\n\t\tDELETE FROM {$wpdb->postmeta}\n\t\tWHERE NOT EXISTS (\n\t\t\tSELECT 1 FROM {$wpdb->posts} tmp WHERE tmp.ID = post_id\n\t\t);\n\t\t";
// Clear all WP transient cache.
$sql[] = "\n\t\tDELETE FROM {$wpdb->options}\n\t\tWHERE option_name LIKE '_transient_%';\n\t\t";
foreach ($sql as $s) {
$wpdb->query($s);
}
// Move Membership pages to trash.
foreach ($trash_ids as $id) {
wp_delete_post($id, true);
}
// Clear all data from WP Object cache.
wp_cache_flush();
// Redirect to the main page.
wp_safe_redirect(MS_Controller_Plugin::get_admin_url());
exit;
}
示例3: get_ms_post_types
/**
* Get post types that are part of this plugin.
*
* @since 1.0.0
*
* @return array The plugin core post types.
*/
public static function get_ms_post_types()
{
$cpts = array(MS_Model_Membership::get_post_type(), MS_Model_Invoice::get_post_type(), MS_Model_Communication::get_post_type(), MS_Model_Relationship::get_post_type(), MS_Model_Event::get_post_type());
return apply_filters('ms_rule_cptgroup_model_get_ms_post_types', $cpts);
}
示例4: get_membership_id
/**
* Returns the membership-ID that matches the specified Membership name or
* slug.
*
* If multiple memberships have the same name then the one with the lowest
* ID (= the oldest) will be returned.
*
* Name or slug are case-IN-sensitive ('slug' and 'SLUG' are identical)
* Wildcards are not allowed, the string must match exactly.
*
* @since 1.0.1.2
* @param string $name_or_slug The Membership name or slug to search.
* @return int|false The membership ID or false.
*/
public function get_membership_id($name_or_slug)
{
global $wpdb;
$res = false;
$sql = "\n\t\tSELECT ID\n\t\tFROM {$wpdb->posts} p\n\t\tINNER JOIN {$wpdb->postmeta} m ON m.post_id = p.ID AND m.meta_key = %s\n\t\tWHERE\n\t\t\tp.post_type = %s\n\t\t\tAND ( m.meta_value = %s OR p.post_name = %s )\n\t\tORDER BY ID\n\t\t;";
MS_Factory::select_blog();
$sql = $wpdb->prepare($sql, 'name', MS_Model_Membership::get_post_type(), $name_or_slug, $name_or_slug);
$ids = $wpdb->get_col($sql);
MS_Factory::revert_blog();
if (is_array($ids) && count($ids)) {
$res = reset($ids);
}
return $res;
}