Code Duplication    Length = 116-116 lines in 2 locations

shortcodely-v1.0.0/shortcodely.php 1 location

@@ 264-379 (lines=116) @@
261
    return $output;
262
}
263
/* -------------------------------------------------------------------------*/
264
function shortcodely_shortcode_sidebar($widget_id,
265
    $name = 'widgets_for_shortcode',
266
    $title = true,
267
    $class = '',
268
    $wrap = '',
269
    $widget_classes = ''
270
) {
271
    /* This is basically the wordpress code, slightly modified	*/
272
    global $wp_registered_sidebars, $wp_registered_widgets;
273
274
    $debug = shortcodely_check_if_widget_debug();
275
276
    $sidebarid = shortcodely_get_sidebar_id($name);
277
278
    $sidebars_widgets = wp_get_sidebars_widgets();
279
280
    $sidebar = $wp_registered_sidebars[$sidebarid]; // has the params etc
281
282
    $did_one = false;
283
284
    /* lifted from wordpress code, keep as similar as possible for now */
285
286
    if (! isset($wp_registered_widgets[$widget_id])) {
287
        return;
288
    } // wp had c o n t i n u e
289
290
                $params = array_merge(
291
                    array(
292
                                array_merge(
293
                                    $sidebar,
294
                                    array(
295
                                    'widget_id' => $widget_id,
296
                                        'widget_name' => $wp_registered_widgets[$widget_id]['name'],
297
                                    )
298
                                ),
299
                    ),
300
                    (array) $wp_registered_widgets[$widget_id]['params']
301
                );
302
303
    $validtitletags = array('h1', 'h2', 'h3', 'h4', 'h5', 'header', 'strong', 'em');
304
    $validwraptags = array('div', 'p', 'main', 'aside', 'section');
305
306
    if (! empty($wrap)) { /* then folks want to 'wrap' with their own html tag, or wrap = yes	*/
307
        if ((! in_array($wrap, $validwraptags))) {
308
            $wrap = '';
309
        }
310
        /* To match a variety of themes, allow for a variety of html tags. */
311
        /* May not need if our sidebar match attempt has worked */
312
    }
313
314
    if (! empty($wrap)) {
315
        $params[0]['before_widget'] = '<' . $wrap . ' id="%1$s" class="%2$s">';
316
        $params[0]['after_widget'] = '</' . $wrap . '>';
317
    }
318
319
                // wp code to get classname
320
                $classname_ = '';
321
                //foreach ( (array) $wp_registered_widgets[$widget_id]['classname'] as $cn ) {
322
                        $cn = $wp_registered_widgets[$widget_id]['classname'];
323
    if (is_string($cn)) {
324
        $classname_ .= '_' . $cn;
325
    } elseif (is_object($cn)) {
326
        $classname_ .= '_' . get_class($cn);
327
    }
328
                //}
329
                $classname_ = ltrim($classname_, '_');
330
331
                // add MKM and others requested class in to the wp classname string
332
                // if no class specfied, then class will = shortcodelywidget.	These classes are so can reverse out unwanted widget styling.
333
334
                // $classname_ .= ' widget '; // wordpress seems to almost always adds the widget class
335
336
                $classname_ .= ' ' . $class;
337
338
                // we are picking up the defaults from the	thems sidebar ad they have registered heir sidebar to issue widget classes?
339
340
                // Substitute HTML id and class attributes into before_widget
341
    if (! empty($params[0]['before_widget'])) {
342
        $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $widget_id, $classname_);
343
    } else {
344
        $params[0]['before_widget'] = '';
345
    }
346
347
    if (empty($params[0]['before_widget'])) {
348
        $params[0]['after_widget'] = '';
349
    }
350
351
    $params = apply_filters('dynamic_sidebar_params', $params);
352
                // allow, any pne usingmust ensure they apply to the correct sidebars
353
354
    if (! empty($title)) {
355
        if ('false' == $title) { /* shortcodely switch off the title html, still need to get rid of title separately */
356
            $params[0]['before_title'] = '<span style="display: none">';
357
            $params[0]['after_title'] = '</span>';
358
        } else {
359
            if (in_array($title, $validtitletags)) {
360
                $class = ' class="widget-title" ';
361
362
                $params[0]['before_title'] = '<' . $title . ' ' . $class . ' >';
363
                $params[0]['after_title'] = '</' . $title . '>';
364
            }
365
        }
366
    }
367
368
    if (! empty($widget_classes) and ('none' == $widget_classes)) {
369
        $params = shortcodely_remove_widget_class($params); // also called in widget area shortcode
370
    }
371
372
    $callback = $wp_registered_widgets[$widget_id]['callback'];
373
    if (is_callable($callback)) {
374
        call_user_func_array($callback, $params);
375
        $did_one = true;
376
    }
377
    //	}
378
    return $did_one;
379
}
380
/* ---------------------------------------------------------------------------*/
381
function shortcodely_reg_sidebar()
382
{

shortcodely.php 1 location

@@ 264-379 (lines=116) @@
261
    return $output;
262
}
263
/* -------------------------------------------------------------------------*/
264
function shortcodely_shortcode_sidebar($widget_id,
265
    $name = 'widgets_for_shortcode',
266
    $title = true,
267
    $class = '',
268
    $wrap = '',
269
    $widget_classes = ''
270
) {
271
    /* This is basically the wordpress code, slightly modified	*/
272
    global $wp_registered_sidebars, $wp_registered_widgets;
273
274
    $debug = shortcodely_check_if_widget_debug();
275
276
    $sidebarid = shortcodely_get_sidebar_id($name);
277
278
    $sidebars_widgets = wp_get_sidebars_widgets();
279
280
    $sidebar = $wp_registered_sidebars[$sidebarid]; // has the params etc
281
282
    $did_one = false;
283
284
    /* lifted from wordpress code, keep as similar as possible for now */
285
286
    if (! isset($wp_registered_widgets[$widget_id])) {
287
        return;
288
    } // wp had c o n t i n u e
289
290
                $params = array_merge(
291
                    array(
292
                                array_merge(
293
                                    $sidebar,
294
                                    array(
295
                                    'widget_id' => $widget_id,
296
                                        'widget_name' => $wp_registered_widgets[$widget_id]['name'],
297
                                    )
298
                                ),
299
                    ),
300
                    (array) $wp_registered_widgets[$widget_id]['params']
301
                );
302
303
    $validtitletags = array('h1', 'h2', 'h3', 'h4', 'h5', 'header', 'strong', 'em');
304
    $validwraptags = array('div', 'p', 'main', 'aside', 'section');
305
306
    if (! empty($wrap)) { /* then folks want to 'wrap' with their own html tag, or wrap = yes	*/
307
        if ((! in_array($wrap, $validwraptags))) {
308
            $wrap = '';
309
        }
310
        /* To match a variety of themes, allow for a variety of html tags. */
311
        /* May not need if our sidebar match attempt has worked */
312
    }
313
314
    if (! empty($wrap)) {
315
        $params[0]['before_widget'] = '<' . $wrap . ' id="%1$s" class="%2$s">';
316
        $params[0]['after_widget'] = '</' . $wrap . '>';
317
    }
318
319
                // wp code to get classname
320
                $classname_ = '';
321
                //foreach ( (array) $wp_registered_widgets[$widget_id]['classname'] as $cn ) {
322
                        $cn = $wp_registered_widgets[$widget_id]['classname'];
323
    if (is_string($cn)) {
324
        $classname_ .= '_' . $cn;
325
    } elseif (is_object($cn)) {
326
        $classname_ .= '_' . get_class($cn);
327
    }
328
                //}
329
                $classname_ = ltrim($classname_, '_');
330
331
                // add MKM and others requested class in to the wp classname string
332
                // if no class specfied, then class will = shortcodelywidget.	These classes are so can reverse out unwanted widget styling.
333
334
                // $classname_ .= ' widget '; // wordpress seems to almost always adds the widget class
335
336
                $classname_ .= ' ' . $class;
337
338
                // we are picking up the defaults from the	thems sidebar ad they have registered heir sidebar to issue widget classes?
339
340
                // Substitute HTML id and class attributes into before_widget
341
    if (! empty($params[0]['before_widget'])) {
342
        $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $widget_id, $classname_);
343
    } else {
344
        $params[0]['before_widget'] = '';
345
    }
346
347
    if (empty($params[0]['before_widget'])) {
348
        $params[0]['after_widget'] = '';
349
    }
350
351
    $params = apply_filters('dynamic_sidebar_params', $params);
352
                // allow, any pne usingmust ensure they apply to the correct sidebars
353
354
    if (! empty($title)) {
355
        if ('false' == $title) { /* shortcodely switch off the title html, still need to get rid of title separately */
356
            $params[0]['before_title'] = '<span style="display: none">';
357
            $params[0]['after_title'] = '</span>';
358
        } else {
359
            if (in_array($title, $validtitletags)) {
360
                $class = ' class="widget-title" ';
361
362
                $params[0]['before_title'] = '<' . $title . ' ' . $class . ' >';
363
                $params[0]['after_title'] = '</' . $title . '>';
364
            }
365
        }
366
    }
367
368
    if (! empty($widget_classes) and ('none' == $widget_classes)) {
369
        $params = shortcodely_remove_widget_class($params); // also called in widget area shortcode
370
    }
371
372
    $callback = $wp_registered_widgets[$widget_id]['callback'];
373
    if (is_callable($callback)) {
374
        call_user_func_array($callback, $params);
375
        $did_one = true;
376
    }
377
    //	}
378
    return $did_one;
379
}
380
/* ---------------------------------------------------------------------------*/
381
function shortcodely_reg_sidebar()
382
{