Exemple #1
0
 /**
  * Returns a new action object built using the information described in $action.
  *
  * The particular type of the resulting action will depend on
  * `$action->type`. Note this class is abstract and there are
  * several concrete classes extending this one.
  *
  * @param object $json a JSON action as used in the admin pages of our plugin.
  *
  * @return boolean|NelioABAction the new action containing all the information in `$action`.
  *
  * @since PHPDOC
  */
 public static function build_action_using_json4js($json)
 {
     require_once NELIOAB_MODELS_DIR . '/goals/actions/page-accessed-action.php';
     require_once NELIOAB_MODELS_DIR . '/goals/actions/form-submission-action.php';
     require_once NELIOAB_MODELS_DIR . '/goals/actions/click-element-action.php';
     require_once NELIOAB_MODELS_DIR . '/goals/actions/wc-order-completed-action.php';
     switch ($json->type) {
         case self::PAGE_ACCESSED:
         case self::POST_ACCESSED:
         case self::EXTERNAL_PAGE_ACCESSED:
             return NelioABPageAccessedAction::build_action_using_json4js($json);
         case self::FORM_SUBMIT:
             return NelioABFormSubmissionAction::build_action_using_json4js($json);
         case self::CLICK_ELEMENT:
             return NelioABClickElementAction::build_action_using_json4js($json);
         case self::WC_ORDER_COMPLETED:
             return NelioABWooCommerceOrderCompletedAction::build_action_using_json4js($json);
         default:
             return false;
     }
 }