@@ -24,55 +24,61 @@ function yourcode_run($message)
24
24
global $ parser ;
25
25
static $ yourcode ;
26
26
27
- // if the parser's MyCode cache is anything other than the default value then we have already been here
28
- if ($ parser ->mycode_cache == 0 )
27
+ /*
28
+ * if the parser isn't valid or its MyCode cache is
29
+ * anything other than the default value then there is
30
+ * nothing to do
31
+ */
32
+ if ($ parser instanceof postParser != true ||
33
+ $ parser ->mycode_cache !== 0 ) {
34
+ return $ message ;
35
+ }
36
+
37
+ // we have to consider several sequential iterations calling the method we have hooked into
38
+ if (!isset ($ yourcode ) || !is_array ($ yourcode ) || empty ($ yourcode ))
29
39
{
30
- // we have to consider several sequential iterations calling the method we have hooked into
31
- if (!isset ($ yourcode ) || !is_array ($ yourcode ) || empty ($ yourcode ))
32
- {
33
- // load the cache if this is the first run
34
- global $ cache ;
35
- $ yourcode = $ cache ->read ('yourcode ' );
36
- }
40
+ // load the cache if this is the first run
41
+ global $ cache ;
42
+ $ yourcode = $ cache ->read ('yourcode ' );
43
+ }
37
44
38
- if (is_array ($ yourcode ['active ' ]['restricted_view ' ]['standard ' ]) && !empty ($ yourcode ['active ' ]['restricted_view ' ]['standard ' ]))
45
+ if (is_array ($ yourcode ['active ' ]['restricted_view ' ]['standard ' ]) && !empty ($ yourcode ['active ' ]['restricted_view ' ]['standard ' ]))
46
+ {
47
+ foreach ($ yourcode ['active ' ]['restricted_view ' ]['standard ' ] as $ code )
39
48
{
40
- foreach ( $ yourcode [ ' active ' ][ ' restricted_view ' ][ ' standard ' ] as $ code )
49
+ if ( $ code [ ' can_view ' ] )
41
50
{
42
- if ($ code ['can_view ' ])
51
+ if (! yourcode_check_user_permissions ( $ code ['can_view ' ]) )
43
52
{
44
- if (!yourcode_check_user_permissions ($ code ['can_view ' ]))
45
- {
46
- $ code ['replacement ' ] = $ code ['alt_replacement ' ];
47
- }
53
+ $ code ['replacement ' ] = $ code ['alt_replacement ' ];
48
54
}
49
- $ yourcode ['active ' ]['simple ' ]['standard ' ]['find ' ][] = $ code ['find ' ];
50
- $ yourcode ['active ' ]['simple ' ]['standard ' ]['replacement ' ][] = $ code ['replacement ' ];
51
55
}
56
+ $ yourcode ['active ' ]['simple ' ]['standard ' ]['find ' ][] = $ code ['find ' ];
57
+ $ yourcode ['active ' ]['simple ' ]['standard ' ]['replacement ' ][] = $ code ['replacement ' ];
52
58
}
59
+ }
53
60
54
- $ yourcode ['active ' ]['simple ' ]['standard_count ' ] = count ($ yourcode ['active ' ]['simple ' ]['standard ' ]);
61
+ $ yourcode ['active ' ]['simple ' ]['standard_count ' ] = count ($ yourcode ['active ' ]['simple ' ]['standard ' ]);
55
62
56
- if (is_array ($ yourcode ['active ' ]['restricted_view ' ]['nestable ' ]) && !empty ($ yourcode ['active ' ]['restricted_view ' ]['nestable ' ]))
63
+ if (is_array ($ yourcode ['active ' ]['restricted_view ' ]['nestable ' ]) && !empty ($ yourcode ['active ' ]['restricted_view ' ]['nestable ' ]))
64
+ {
65
+ foreach ($ yourcode ['active ' ]['restricted_view ' ]['nestable ' ] as $ code )
57
66
{
58
- foreach ( $ yourcode [ ' active ' ][ ' restricted_view ' ][ ' nestable ' ] as $ code )
67
+ if ( $ code [ ' can_view ' ] )
59
68
{
60
- if ($ code ['can_view ' ])
69
+ if (! yourcode_check_user_permissions ( $ code ['can_view ' ]) )
61
70
{
62
- if (!yourcode_check_user_permissions ($ code ['can_view ' ]))
63
- {
64
- $ code ['replacement ' ] = $ code ['alt_replacement ' ];
65
- }
71
+ $ code ['replacement ' ] = $ code ['alt_replacement ' ];
66
72
}
67
- $ yourcode ['active ' ]['simple ' ]['nestable ' ][] = array ('find ' => $ code ['find ' ], 'replacement ' => $ code ['replacement ' ]);
68
73
}
74
+ $ yourcode ['active ' ]['simple ' ]['nestable ' ][] = array ('find ' => $ code ['find ' ], 'replacement ' => $ code ['replacement ' ]);
69
75
}
76
+ }
70
77
71
- $ yourcode ['active ' ]['simple ' ]['nestable_count ' ] = count ($ yourcode ['active ' ]['simple ' ]['nestable ' ]);
72
- $ yourcode ['active ' ]['simple ' ]['callback_count ' ] = count ($ yourcode ['active ' ]['simple ' ]['callback ' ]);
78
+ $ yourcode ['active ' ]['simple ' ]['nestable_count ' ] = count ($ yourcode ['active ' ]['simple ' ]['nestable ' ]);
79
+ $ yourcode ['active ' ]['simple ' ]['callback_count ' ] = count ($ yourcode ['active ' ]['simple ' ]['callback ' ]);
73
80
74
- $ parser ->mycode_cache = $ yourcode ['active ' ]['simple ' ];
75
- }
81
+ $ parser ->mycode_cache = $ yourcode ['active ' ]['simple ' ];
76
82
77
83
// give back what was freely given to us
78
84
return $ message ;
0 commit comments