/** * Handle the display of smart layers via CSS. * * @since 1.0.0 */ function handle_smart_layers() { $css = '.addthis-smartlayers{display:none;}.dp-addthis .addthis-smartlayers{display:block;}'; $rules = dp_addthis_get_rules('smart_layers'); if (!empty($rules)) { $contexts = dp_addthis_get_contexts(); $tools = dp_addthis_get_tools(array('is_smartlayer' => true)); foreach ($rules as $rule) { if (!in_array($rule['context'], $contexts)) { continue; } $tool = $rule['tool']; if (!empty($tools[$tool]['selector'])) { $css .= $tools[$tool]['selector'] . '{display:block;}'; } } } echo "\n<!-- Smart Layers CSS by (dp) AddThis START -->"; echo "\n" . '<style type="text/css">' . $css . '</style>'; echo "\n<!-- Smart Layers CSS by (dp) AddThis END -->\n"; }
function render_smart_layer($index, $rule = '') { $basename = 'dp_addthis_smart_layers_display_rules[' . $index . ']'; $is_pro = get_option('dp_addthis_is_pro'); $rule = wp_parse_args($rule, array('tool' => '', 'context' => '', 'location' => '')); ?> <tr> <td> <?php // build choices $tool_args = array('is_smartlayer' => true); if (!$is_pro) { $tool_args['is_pro'] = false; } $tools = dp_addthis_get_tools($tool_args); $choices = array(); foreach ($tools as $key => $tool) { $label = $tool['label']; if ($tool['is_pro']) { $label .= ' (AddThis Pro)'; } $choices[$key] = $label; } // render field $this->render_field(array('type' => 'select', 'name' => $basename . '[tool]', 'choices' => $choices, 'value' => $rule['tool'])); ?> </td> <td> <?php // build choices $contexts = dp_addthis_get_context_objects(); $choices = array(); foreach ($contexts as $key => $context) { $choices[$key] = $context['label']; } // render field $this->render_field(array('type' => 'select', 'name' => $basename . '[context]', 'choices' => $choices, 'value' => $rule['context'])); ?> </td> <td class="delete"> <button class="delete-item button">×</button> </td> </tr> <?php }