A free points management plugin for WordPress.
myCRED Logo
myCRED Logo
  • Membership New
  • Chapters
    • Chapter I – Introduction
    • Chapter II – Getting Started
    • Chapter III – Add-ons
    • Chapter IV – Premium Add-ons
    • Chapter V – For Developers
    • Chapter VI – Reference Guides
  • Categories
    • Actions
    • Classes
    • Constants
    • Filters
    • Functions
    • Objects
    • Shortcodes
    • Hooks
    • Template Tags
  • Packages
    • mycred/api
    • mycred/badge
    • mycred/balance
    • mycred/banking
    • mycred/content
    • mycred/core
    • mycred/coupon
    • mycred/email
    • mycred/game
    • mycred/log
    • mycred/notice
    • mycred/payment
    • mycred/purchase
    • mycred/rank
    • mycred/transfer
  • Store
  • Download
    Navigation
    • Loading navigation ...
    All Objects
    myCRED objects
    1. myCRED_Account
    2. myCRED_Badge
    3. myCRED_Balance
    4. myCred_Chart
    5. myCRED_Email
    6. myCRED_History
    7. myCRED_Point_Type
    8. myCRED_Rank
    9. myCRED_Transfer
    Categories
    Filter by category
    1. Actions
    2. Classes
    3. Filters
    4. Functions
    5. Hooks
    6. Objects
    7. Shortcodes
    8. Template Tags
    Chapters
    Documentation
    1. Chapter I - Introduction
    2. Chapter II - Getting Started
    3. Chapter III - Add-ons
    4. Chapter IV - Premium Add-ons
    5. Chapter V - For Developers
    6. Chapter VI - Reference Guides
myCRED_Point_Type

Codex / mycred/balance / Objects / myCRED_Point_Type

Description

The myCRED_Point_Type object holds the structure and formatting of a given point type. It is used to ensure values are formatted correctly and are valid. It is used for both calculations as well as displaying or rendering point values.

Available since version 1.7

Object Properties

Note that the constructor class will auto populate these values when the class is constructed.

Property Type Description
myCRED_Point_Type Object (
public $cred_id string The point type key.
public $singular string The point types given name in singular form.
public $plural string The point types given name in plural form.
public $prefix string The set prefix for this point type (if used).
public $suffix string The set suffix for this point type (if used).
public $format array An associated array about the format set for this point type. this includes:
  • type The type format used in the database. Bigint or decimal.
  • decimals The number of decimal places used for this point type.
  • separators An array containing the decimal and thousand separators.
public $lowest_value int or float This is the lowest point value that can be processed based on the format setup.
)
Object Methods
public function __construct( $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
Description: Constructs the point type object based on a point type key.
Variable Type Required Description
$point_type string Yes The point type key.
}
public function get_lowest_value() {
Description: Returns the lowest amount this point type setup can handle. For point types that use integers, this will be 1 while if using two decimal places, it would be 0.01. Used to ensure myCRED does not attempt to handle partial points.
}
public function number( $number = '' ) {
Description: Formats a given value based on the format setup used by this point type. A point type that uses decimals will be returned as a float else an integer.
Variable Type Required Description
$number string Yes A value that is to be converted into an int or float based on the point type setup.
}
public function format( $number = '' ) {
Description: Returns a given value in a string form with separators, prefix or suffix applied. This method should only be used to display values and not for calculations.
Variable Type Required Description
$number string Yes The point value to format.
}
Object Example
myCRED_Point_Type Object
(
    [cred_id] => mycred_deed
    [singular] => Deed
    [plural] => Deeds
    [prefix] => 
    [suffix] => de.
    [format] => Array
        (
            [type] => bigint
            [decimals] => 0
            [separators] => Array
                (
                    [decimal] => .
                    [thousand] => ,
                )

        )
    [lowest_value] => 1
)
0

About myCred

myCred is a free, open-source and developer friendly points management tool for WordPress powered websites.

Download Rate Plugin

Documentation

  • Add-ons
  • Core Shortcodes
  • F.A.Q.
  • Tutorials
  • Third Party Plugins
  • Code Snippets

Support

  • Product Licenses
  • Customization
  • Support Forums
  • Plugin Changelog
  • Contact

Copyright 2013 - 2021 by WPExperts; All rights reserved. myCred is licensed under GPL 2.0

Terms & Conditions • Use of Cookies • Store Policy • Community Rules

Suggest Codex Example

You can submit suggestions for codex examples that you have available as a public gist. If you are a member on the mycred.me website, you can earn Tokens for each submission. To claim these Tokens, make sure you provide your mycred.me username.

Please make sure the example you submit is relevant and if you include documentation, it's provided in English.

logo
  • Membership New
  • Chapters
    • Chapter I – Introduction
    • Chapter II – Getting Started
    • Chapter III – Add-ons
    • Chapter IV – Premium Add-ons
    • Chapter V – For Developers
    • Chapter VI – Reference Guides
  • Categories
    • Actions
    • Classes
    • Constants
    • Filters
    • Functions
    • Objects
    • Shortcodes
    • Hooks
    • Template Tags
  • Packages
    • mycred/api
    • mycred/badge
    • mycred/balance
    • mycred/banking
    • mycred/content
    • mycred/core
    • mycred/coupon
    • mycred/email
    • mycred/game
    • mycred/log
    • mycred/notice
    • mycred/payment
    • mycred/purchase
    • mycred/rank
    • mycred/transfer
  • Store
  • Download