public static function get_shortcodes($content, $form_id) { if (empty($form_id) || strpos($content, '[') === false) { // don't continue if there are no shortcodes to check return array(array()); } $tagregexp = array('deletelink', 'detaillink', 'evenodd', 'get', 'entry_count', 'event_date'); $form_id = (int) $form_id; $form_ids = array($form_id); //get linked form ids $fields = FrmProFormsHelper::has_repeat_field($form_id, false); foreach ($fields as $field) { if (FrmField::is_option_true($field, 'form_select')) { $form_ids[] = $field->field_options['form_select']; $tagregexp[] = $field->id; $tagregexp[] = $field->field_key; } unset($field); } foreach ($form_ids as $form_id) { $fields = FrmField::get_all_for_form($form_id, '', 'include'); foreach ($fields as $field) { $tagregexp[] = $field->id; $tagregexp[] = $field->field_key; } } $tagregexp = implode('|', $tagregexp) . '|'; $tagregexp .= FrmFieldsHelper::allowed_shortcodes(); if (!ini_get('safe_mode')) { // make sure the backtrack limit is as least at the default $backtrack_limit = ini_get('pcre.backtrack_limit'); if ($backtrack_limit < 1000000) { ini_set('pcre.backtrack_limit', 1000000); } } preg_match_all("/\\[(if |foreach )?({$tagregexp})\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/\\])?/s", $content, $matches, PREG_PATTERN_ORDER); // run conditional and foreach first $new_order = $matches[0]; $move_up = array(); foreach ($new_order as $short_key => $tag) { $conditional = preg_match('/^\\[if/s', $matches[0][$short_key]) ? true : false; $foreach = preg_match('/^\\[foreach/s', $matches[0][$short_key]) ? true : false; if ($conditional || $foreach) { $move_up[$short_key] = $tag; } } if (!empty($move_up)) { $matches[0] = $move_up + $matches[0]; } return $matches; }