get_default_permissions($type)); /* * Case post type disabled. */ if (!$post_type_limit->enabled) { return false; } // end if; /* * Case unlimited posts */ if (absint($post_type_limit->number) === 0) { return true; } // end if; return absint($value_to_check) < absint($post_type_limit->number); } // end check; /** * Adds a magic getter for subtypes. * * @since 2.0.0 * * @param string $sub_type The sub type. * @return object */ public function __get($sub_type) { $type = (object) wu_get_isset($this->get_limit(), $sub_type, $this->get_default_permissions($sub_type)); return (object) wp_parse_args($type, $this->get_default_permissions($sub_type)); } // end __get; /** * Returns default permissions. * * @since 2.0.0 * * @param string $type Type for sub-checking. * @return array */ public function get_default_permissions($type) { return array( 'enabled' => true, 'number' => '', // unlimited ); } // end get_default_permissions; /** * Checks if a theme exists on the current module. * * @since 2.0.0 * * @param string $type The type. * @return bool */ public function exists($type) { $results = wu_get_isset($this->get_limit(), $type, array()); return wu_get_isset($results, 'number', 'not-set') !== 'not-set'; } // end exists; /** * Handles limits on post submission. * * @since 2.0.0 * @return mixed */ public function handle_limit() { $received = wu_get_isset($_POST['modules'][$this->id], 'limit', array()); foreach ($received as $post_type => &$limitations) { $limitations['enabled'] = (bool) wu_get_isset($_POST['modules'][$this->id]['limit'][$post_type], 'enabled', false); } // end foreach; return $received; } // end handle_limit; } // end class Limit_Subtype;