/** * is_allowed * Determines if a workflow tab is allowed to be shown. * * @param array $data The tab configuration object. * * @return array The statuse of whether its allowed. * * @access public * @static * @since 1.0 */ public static function is_allowed($data, $strict = true) { global $pagenow; $allowed = !$strict; // Check to see if there is an active flow if (isset($_REQUEST['flow']) && piklist::slug($flow, 'UTF-8') == $_REQUEST['flow']) { $allowed = true; } // Check Pages $pages = $data['data']['page']; if (!empty($pages)) { $allowed = in_array($pagenow, $pages); if (isset($_REQUEST['page'])) { $allowed = in_array($_REQUEST['page'], $pages); } } // Check Post Types if ($allowed && piklist_admin::is_post()) { $post_types = $data['data']['post_type']; $current_post_type = piklist_cpt::detect_post_type(); if (!empty($post_types)) { $allowed = in_array($current_post_type, $post_types); } } // Check which mode we are on for the term pages if (piklist_admin::is_term()) { $taxonomies = $data['data']['taxonomy']; $current_taxonomy = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : false; if (!empty($taxonomies) && $current_taxonomy) { $allowed = in_array($current_taxonomy, $taxonomies); } if (piklist_admin::is_term() === 'new') { $allowed = false; } } return $allowed; }
/** * get_field_scope * Get the field scope based off of environment. * * @return string The field scope. * * @access public * @static * @since 1.0 */ public static function get_field_scope() { global $pagenow; $scope = null; if (piklist_admin::is_post()) { $scope = 'post_meta'; } elseif (piklist_admin::is_media()) { $scope = 'post_meta'; } elseif (piklist_admin::is_term()) { $scope = 'term_meta'; } elseif (piklist_admin::is_user()) { $scope = 'user_meta'; } elseif ($pagenow == 'admin.php' && isset($_REQUEST['page']) && $_REQUEST['page'] == 'shortcode_editor') { $scope = 'shortcode'; } return $scope; }