@@ -28,24 +28,24 @@ function unmus_seo_framework_filter_stack() {
2828
2929 // Disable Cannonical for Archives and Pages without Content
3030 if ( is_archive () OR is_search () OR ( is_paged () AND is_home () ) OR is_page ('wordpress ' ) OR is_page ('notify-me ' )) {
31- add_filter ( ' the_seo_framework_rel_canonical_output ' , ' __return_false ' );
31+ add_filter (' the_seo_framework_meta_render_data ' , ' unmus_seo_framework_meta_remove_canonical ' );
3232 }
3333
3434 // Create Next, Create Previous & Overwrite Canonicals @ Mathilda
3535 if (function_exists ('mathilda_activate ' )) {
3636 if ( mathilda_is_tweet_page () ) {
37- add_filter ( ' the_seo_framework_paged_url_output_prev ' , ' mathilda_prev_meta_output ' );
38- add_filter ( ' the_seo_framework_paged_url_output_next ' , ' mathilda_next_meta_output ' );
39- add_filter ( ' the_seo_framework_rel_canonical_output ' , ' mathilda_canonical ' );
37+ add_filter (' the_seo_framework_meta_render_data ' , ' mathilda_set_prev ' );
38+ add_filter (' the_seo_framework_meta_render_data ' , ' mathilda_set_next ' );
39+ add_filter (' the_seo_framework_meta_render_data ' , ' mathilda_set_canonical ' );
4040 }
4141 }
4242
4343 // Create Next, Create Previous & Overwrite Canonicals @ TootPress
4444 if (function_exists ('tootpress_activate ' )) {
4545 if ( tootpress_toot_here () ) {
46- add_filter ( ' the_seo_framework_paged_url_output_prev ' , ' tootpress_prev_meta_output ' );
47- add_filter ( ' the_seo_framework_paged_url_output_next ' , ' tootpress_next_meta_output ' );
48- add_filter ( ' the_seo_framework_rel_canonical_output ' , ' tootpress_canonical ' );
46+ add_filter (' the_seo_framework_meta_render_data ' , ' tootpress_set_prev ' );
47+ add_filter (' the_seo_framework_meta_render_data ' , ' tootpress_set_next ' );
48+ add_filter (' the_seo_framework_meta_render_data ' , ' tootpress_set_canonical ' );
4949 }
5050 }
5151
@@ -223,9 +223,11 @@ function mathilda_prev_meta_output() {
223223
224224 $ mathilda_subpage =mathilda_which_page ();
225225 $ number_of_pages =mathilda_pages ();
226-
227226 $ mathilda_permalink =get_permalink ();
228- $ mathilda_permalink =$ mathilda_permalink . ($ mathilda_subpage -1 )."/ " ;
227+
228+ if ($ mathilda_subpage >2 ) {
229+ $ mathilda_permalink =$ mathilda_permalink . ($ mathilda_subpage -1 )."/ " ;
230+ }
229231
230232 if ($ mathilda_subpage ==1 ) {
231233 $ mathilda_permalink =false ;
@@ -281,10 +283,12 @@ function tootpress_prev_meta_output() {
281283
282284 $ tootpress_subpage =tootpress_get_query_var ();
283285 $ number_of_pages =tootpress_amount_of_pages ();
284-
285286 $ tootpress_permalink =get_permalink ();
286- $ tootpress_permalink =$ tootpress_permalink . ($ tootpress_subpage -1 )."/ " ;
287-
287+
288+ if ($ tootpress_subpage >2 ) {
289+ $ tootpress_permalink =$ tootpress_permalink . ($ tootpress_subpage -1 )."/ " ;
290+ }
291+
288292 if ($ tootpress_subpage ==1 ) {
289293 $ tootpress_permalink =false ;
290294 }
@@ -294,4 +298,176 @@ function tootpress_prev_meta_output() {
294298 }
295299}
296300
301+ // TSF 5.0
302+ // New technical approach
303+ // Background: depreciated filters
304+
305+ /**
306+ * Removes the Canonical Link
307+ *
308+ * @since 0.8
309+ *
310+ * @param array $tags_render_data
311+ * @return array $tags_render_data
312+ */
313+
314+ function unmus_seo_framework_meta_remove_canonical ($ tags_render_data ) {
315+
316+ unset( $ tags_render_data ['canonical ' ] );
317+ return $ tags_render_data ;
318+
319+ }
320+
321+ /**
322+ * Set Tootpress Canonical
323+ *
324+ * @since 0.8
325+ *
326+ * @param array $tags_render_data
327+ * @return array $tags_render_data
328+ */
329+
330+ function tootpress_set_canonical ($ tags_render_data ) {
331+
332+ $ tags_render_data ['canonical ' ]['attributes ' ]['href ' ] = tootpress_canonical ();
333+ return $ tags_render_data ;
334+
335+ }
336+
337+ /**
338+ * Set Tootpress Next Link
339+ *
340+ * @since 0.8
341+ *
342+ * @param array $tags_render_data
343+ * @return array $tags_render_data
344+ */
345+
346+ function tootpress_set_next ($ tags_render_data ) {
347+
348+ $ next_meta_content =tootpress_next_meta_output ();
349+
350+ if ($ next_meta_content !='' ) {
351+
352+ $ tags_render_data ['next ' ] = [
353+
354+ 'tag ' => 'link ' ,
355+ 'attributes ' => [
356+ 'rel ' => 'next ' ,
357+ 'href ' => $ next_meta_content ,
358+ ]
359+ ];
360+
361+ }
362+
363+ return $ tags_render_data ;
364+
365+ }
366+
367+ /**
368+ * Set Tootpress Prev Link
369+ *
370+ * @since 0.8
371+ *
372+ * @param array $tags_render_data
373+ * @return array $tags_render_data
374+ */
375+
376+ function tootpress_set_prev ($ tags_render_data ) {
377+
378+ $ prev_meta_content =tootpress_prev_meta_output ();
379+
380+ if ($ prev_meta_content !='' ) {
381+
382+ $ tags_render_data ['prev ' ] = [
383+
384+ 'tag ' => 'link ' ,
385+ 'attributes ' => [
386+ 'rel ' => 'prev ' ,
387+ 'href ' => $ prev_meta_content ,
388+ ]
389+ ];
390+
391+ }
392+
393+ return $ tags_render_data ;
394+
395+ }
396+
397+ /**
398+ * Set Mathilda Canonical
399+ *
400+ * @since 0.8
401+ *
402+ * @param array $tags_render_data
403+ * @return array $tags_render_data
404+ */
405+
406+ function mathilda_set_canonical ($ tags_render_data ) {
407+
408+ $ tags_render_data ['canonical ' ]['attributes ' ]['href ' ] = mathilda_canonical ();
409+ return $ tags_render_data ;
410+
411+ }
412+
413+ /**
414+ * Set Mathilda Next Link
415+ *
416+ * @since 0.8
417+ *
418+ * @param array $tags_render_data
419+ * @return array $tags_render_data
420+ */
421+
422+ function mathilda_set_next ($ tags_render_data ) {
423+
424+ $ next_meta_content =mathilda_next_meta_output ();
425+
426+ if ($ next_meta_content !='' ) {
427+
428+ $ tags_render_data ['next ' ] = [
429+
430+ 'tag ' => 'link ' ,
431+ 'attributes ' => [
432+ 'rel ' => 'next ' ,
433+ 'href ' => $ next_meta_content ,
434+ ]
435+ ];
436+
437+ }
438+
439+ return $ tags_render_data ;
440+
441+ }
442+
443+ /**
444+ * Set Mathilda Prev Link
445+ *
446+ * @since 0.8
447+ *
448+ * @param array $tags_render_data
449+ * @return array $tags_render_data
450+ */
451+
452+ function mathilda_set_prev ($ tags_render_data ) {
453+
454+ $ prev_meta_content =mathilda_prev_meta_output ();
455+
456+ if ($ prev_meta_content !='' ) {
457+
458+ $ tags_render_data ['prev ' ] = [
459+
460+ 'tag ' => 'link ' ,
461+ 'attributes ' => [
462+ 'rel ' => 'prev ' ,
463+ 'href ' => $ prev_meta_content ,
464+ ]
465+ ];
466+
467+ }
468+
469+ return $ tags_render_data ;
470+
471+ }
472+
297473?>
0 commit comments