'Display Addpoll.com Content')
);
}
public function form($instance) {
echo '
';
}
public function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['code'] = strip_tags($new_instance['code']);
return $instance;
}
public function widget($args, $instance) {
echo '' . addpoll_tag_parse($instance['code']) . '';
}
}
add_action('widgets_init', create_function('', 'register_widget("AddPollWidget");'));
function addpoll_tag_parse($content) {
$_matches = array();
preg_match_all('/\[addpoll\s?([a-z]+)id="?([0-9]+)"?(\surl=([^\]^\s]+))?(\swidth=([0-9]{0,4}))?(\sheight=([0-9]{0,4}))?(\sautoResize=(true|false))?\]/i', $content, $_matches);
if ( !isset($_matches[1]) ) {
return $content;
}
foreach ( $_matches[1] AS $index=>$section ) {
$f = 'addpoll_' . $section . '_parse';
if ( !function_exists($f) ) {
continue;
}
$content = $f($content, $_matches, $index);
}
return $content;
}
function addpoll_poll_parse($content, $_matches, $index) {
if ( !isset($_matches[2][$index]) ) {
return $content;
}
$id = (int)$_matches[2][$index];
$width = isset($_matches[6][$index]) && !empty($_matches[6][$index]) ? (int)$_matches[6][$index] : 0;
return str_replace($_matches[0][$index], '' . "", $content);
}
function addpoll_survey_parse($content, $_matches, $index) {
if ( !isset($_matches[2][$index]) ) {
return $content;
}
$id = (int)$_matches[2][$index];
if ( !isset($_matches[4]) ) {
return $content;
}
$url = (string)$_matches[4][$index];
$width = isset($_matches[6][$index]) && !empty($_matches[6][$index]) ? (int)$_matches[6][$index] : 0;
$height = isset($_matches[8][$index]) && !empty($_matches[8][$index]) ? (int)$_matches[8][$index] : 0;
$autoResize = isset($_matches[10][$index]) && !empty($_matches[10][$index]) ? (string)$_matches[10][$index] : 'true';
return str_replace($_matches[0][$index], '
" .
'", $content);
}
function addpoll_quiz_parse($content, $_matches, $index) {
return addpoll_survey_parse($content, $_matches, $index);
}
function addpoll_form_parse($content, $_matches, $index) {
return addpoll_survey_parse($content, $_matches, $index);
}
add_filter('the_content', 'addpoll_tag_parse');
?>